Reputation: 336
Hello I am using moment to create a week Calendar:
Current Week #26 -> From Sunday June 27th to Saturday July 3th
const year = 2021;
const week = 26;
moment().year(year).week(week). // prints Sun Jun 20 2021 10:36:14 GMT-0500
Why I obtain the previous week ?
Short Answer I can plus one, but I do not understand why :(
BAD thing:
const startDay = moment(
moment().year(year).week(week + 1)
)
.startOf('week');
const endDay = moment(
moment().year(year).week(week + 1)
)
.endOf('week');
Extra info:
moment().year(2021).week(1) // Sun Dec 27 2020 10:51:41 GMT-0600
instead of January 3th to January 9th
Upvotes: 0
Views: 44
Reputation: 33
Try using moment.utc
which should convert all the dates according to the Universal time
Upvotes: 1