Created
May 8, 2018 19:53
-
-
Save jamesattard/f7919b9ca5ec758ba8293eba58084349 to your computer and use it in GitHub Desktop.
Create a moment.js time range based on arbitrary duration, start time and end time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timeRangeArr = []; | |
const lunchBreakFrom = moment() | |
.hours(12) | |
.minutes(0); | |
const lunchBreakTo = moment() | |
.hours(13) | |
.minutes(0); | |
const duration = 15; | |
for ( | |
let lunchBreak = lunchBreakFrom; | |
lunchBreak.isBefore(lunchBreakTo); | |
lunchBreak.add(duration, "minutes") | |
) { | |
timeRangeArr.push(moment(lunchBreak)); | |
} | |
// console.log(timeRangeArr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment