简体   繁体   中英

days of the week in the same month, moment.js

is there any way to get the days of a week that belong to a same month from a Date Object?

I mean, if saturday is 1 and sunday 2, the week would be just 1 and 2 in a week from monday to sunday. The days from monday to friday would be a previous week form me in this example.

Thanks in advance.

If I did understand you correctly you are looking for something like this

var startDate = moment([2007, 0, 29]);
var endDate = startDate.endOf('week');
var numberOfDaysInBetween = startDate.diff(endDate, 'days');

to include the start day add +1 to number of days in between

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM