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}周`;
}
w1 2 ... 52 53wo1st 2nd ... 52nd 53rdww01 02 ... 52 53W1 2 ... 52 53Wo1st 2nd ... 52nd 53rdWW01 02 ... 52 53Just
moment().format('W')will do