JSFiddle - React, Tailwind, and code Playground
HTML
<div id="time"></div>
JavaScript
var setIntervals = function (start, end, inc) {
start = start.toString().split(':');
end = end.toString().split(':');
inc = parseInt(inc, 10);
var pad = function (n) { return (n < 10) ? '0' + n.toString() : n; },
startHr = parseInt(start[0], 10),
startMin = parseInt(start[1], 10),
endHr = parseInt(end[0], 10),
endMin = parseInt(end[1], 10),
currentHr = startHr,
currentMin = startMin,
previous = currentHr + ':' + pad(currentMin),
current = '',
r = [];
do {
currentMin += inc;
if ((currentMin % 60) === 0 || currentMin > 60) {
currentMin = (currentMin === 60) ? 0 : currentMin - 60;
currentHr += 1;
}
current = currentHr + ':' + pad(currentMin);
r.push(previous + ' - ' + current);
previous = current;
} while (previous !== endHr+':'+endMin );
return r;
};
var timeInterVals=setIntervals("09:00","09:30","15");
$('#time').text(timeInterVals)