Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Used momentJS library
- function getTimeStops(end){
- var roundedUp, startTime, endTime, timeStops;
- roundedUp = Math.ceil(moment().utc().minute() / 30) * 30;
- startTime = moment().utc().set({minute:roundedUp});
- endTime = moment(end, 'HH:mm');
- if( endTime.isBefore(startTime) ){
- endTime.add(1, 'day');
- }
- timeStops = [];
- while(startTime <= endTime){
- timeStops.push(new moment(startTime).format('HH:mm'));
- startTime.add(15, 'minutes');
- }
- return timeStops;
- }
- var timeStops = getTimeStops('02:00');
- console.log('timeStops ', timeStops);
Add Comment
Please, Sign In to add comment