I\'m trying to create an array of times (strings, not Date objects) for every X minutes throughout a full 24 hours. For example, for a 5 minute interval the arr
The result of this is an array times converted into markup that I place in a object. I found that underscore.js's _.range allows me to step through increments but only as integers. So, I used moment.js to convert to unix time. I needed to iterate over minutes slottime, but other intervals can be accomplished with the multiplier, again in my case 60000 making minutes added to valueOf().
function slotSelect(blockstart, blockend, slottime) {
var markup = "";
var secs = parseInt(slottime * 60000); // steps
var a = parseInt( moment(blockstart).valueOf() ); // start
var b = parseInt( moment(blockend).valueOf() );
var times = _.range(a, b, secs);
_.find( times, function( item ) {
var appttime = moment(item).format('h:mm a');
var apptunix = moment(item).format();
markup += ''+"\n";
});
return markup;
}