i am trying to create a time array, something like:
1:00
1:15
1:30
1:45
2:00
2:15
...
here is my code, what it does is that it starts the time from current time upwoards:
var timeArray = [];
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
for (var i = h; i <= 24; i++) {
for (var j = m; j <= 59; j++) {
if (j % 15 === 0) {
j = j === 0 ? '00' : j;
if (i >= 12) {
timeArray.push((i - 12) + ':' + j + ' PM');
} else {
timeArray.push(i + ':' + j + ' AM');
}
}
}
}
the problem is that is m is over 46, like var m = 50;, then the array goes empty because j % 15 doesn't get 0 no more.
an ideas how to fix this?
thanks
hbehoursandmbeminutes?