JSFiddle - React, Tailwind, and code Playground
by pradeep
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="dates"></div>
JavaScript
function addMinutes(time, minutes) {
var date = new Date(new Date('01/01/2015 ' + time).getTime() + minutes * 60000);
var tempTime = ((date.getHours().toString().length == 1) ? '0' + date.getHours() : date.getHours()) + ':' +
((date.getMinutes().toString().length == 1) ? '0' + date.getMinutes() : date.getMinutes()) + ':' +
((date.getSeconds().toString().length == 1) ? '0' + date.getSeconds() : date.getSeconds());
return tempTime;
}
var starttime = "10:00:00";
var interval = "100";
var endtime = "7:00:00";
var timeslots = [starttime];
while (starttime != endtime) {
starttime = addMinutes(starttime, interval);
timeslots.push(starttime);
}
$("#dates").html(timeslots+"</br>");