// 1440 minutes make up a day
// which means there are 48 times in which we can can count 30 minutes
// you basically want to run a for loop 48 times to do the operation of creating 30 minutes time intervals
let timeArr = []
let theTime
// get the time in format of hour and minutes
let today = moment().format('h:mm:ss');
for (let i = 0; i < 1440; i++ ) {
// increase the no if minutes being added by 30 minutes, this will run for 48 times which is the equivalent of a day i.e 30 * 48 = 1440
i += 30
// add 30 minutes to the date
theTime = moment(today, 'h:mm:ss a').add(i, 'minutes').format();
//push into an array
timeArr.push(moment(theTime).format('h:mm:ss'))
console.log(theTime)
}
console.log(timeArr)
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.