Monirul Islam
Monirul Islam

Reputation: 85

Getting date by Year and Week number and get Week Number and Year Number back

I'm trying to generate date by year, week and day number i.e

let date = moment().year(2019).isoWeek(1).isoWeekday(1).toDate(); 
//Mon Dec 31 2018 11:56:45 GMT+0100 (Central European Standard Time)

the problem i'm facing when i want to get year and week from this generated date

moment(date).year() //2018 
moment(date).isoWeek() // 1 

NOT SURE HOW TO SOLVE THIS

Upvotes: 0

Views: 48

Answers (1)

str
str

Reputation: 44969

Read the documentation about year accessors and you will find the Week Year (ISO) section:

moment(date).isoWeekYear() // 2019 

Upvotes: 1

Related Questions