How can i make the function round to nearest 15 minute, not rounding down? if its 10:46 it would round to 11:00
jsfiddle: https://jsfiddle.net/31L9d08s/
code:
var now = new Date();
var Minutes = now.getMinutes();
var quarterHours = Math.round(Minutes/15);
if (quarterHours == 4)
{
now.setHours(now.getHours()+1);
}
var rounded = (quarterHours*15)%60;
now.setMinutes(rounded);
now.setSeconds(0);
now.setMilliseconds(0);
console.log(now.getTime());
var currentdate = new Date(now.getTime());
var datetime = "Last Sync: " + currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
console.log(datetime);