javascript - Get the week as full dates from moment? -


i looking entire week full dates ie:

sun sep 18 2016 00:00:00 gmt-0500 mon sep 19 2016 00:00:00 gmt-0500 tue sep 20 2016 00:00:00 gmt-0500 wed sep 21 2016 00:00:00 gmt-0500 thu sep 22 2016 00:00:00 gmt-0500 fri sep 23 2016 00:00:00 gmt-0500 sat sep 24 2016 00:00:00 gmt-0500

im building infinite scroll calendar , need 1 week @ time based on moment().startof('week').tostring() or whichever method best...

moment.weekdays() gets me part of way there, if moment.weekdays().robust() ideal... , direction welcomed , appreciated!

okay, came solution, works now...

const start = moment().startof('week').weekday(0) const week = [...array(7)].map((_, i) => { return start.add('d', 1).format('mmmm yyyy') })

returns:

//[ 'september 19th 2016', // 'september 20th 2016', // 'september 21st 2016', // 'september 22nd 2016', // 'september 23rd 2016', // 'september 24th 2016', // 'september 25th 2016' ]

also:

const start = moment().startof('week').weekday(-1) const layout = [...array(7)].map((_, i) => { return start.add('d', 1).utc().tostring() })

for utc formatting starting sunday...


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -