Skip to content

Instantly share code, notes, and snippets.

@Chun-Yang
Created August 3, 2017 15:39
Show Gist options
  • Save Chun-Yang/968a730008e3e3ef0b01b700cdfa628b to your computer and use it in GitHub Desktop.
Save Chun-Yang/968a730008e3e3ef0b01b700cdfa628b to your computer and use it in GitHub Desktop.
start = moment('7/31/2017')
end = moment('10/31/2017')
function format(m) {
return m.format('MM/DD/YYYY')
}
for (var i = 0; i < end.diff(start, 'day'); i += 7) {
startOfWeek = moment(start).add(i, 'day').isoWeekday(1)
endOfWeek = moment(start).add(i, 'day').isoWeekday(5)
console.log(format(startOfWeek) + ' - ' + format(endOfWeek))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment