Reputation: 21
I need to convert the timestamp to the week of the year, and use it with the time selector of antd. I only found the following method, which is the method to get the week of the month. Does anyone know how to get the week of the year?
function weekOfMonth (m: any) {
return Math.ceil(m.date() / 7);
}
function getYearWeek (weekData: any) {
const startDate = moment(weekData).startOf('week');
let weekMonth = weekOfMonth(startDate);
let date = startDate.format('YYYY年MM月');
return `${date}第${weekMonth}周`;
}
Upvotes: 1
Views: 58
Reputation: 299
w
1 2 ... 52 53
wo
1st 2nd ... 52nd 53rd
ww
01 02 ... 52 53
W
1 2 ... 52 53
Wo
1st 2nd ... 52nd 53rd
WW
01 02 ... 52 53
Just moment().format('W')
will do
Upvotes: 0