function curWeek(){
const today = new Date();
let firstDayOfYear = new Date(today.getFullYear(), 0, 1);
const dayOfWeek = firstDayOfYear.getDay();
let spendDay = 1;
if (dayOfWeek != 0) {
spendDay = 7 - dayOfWeek + 1;
}
firstDayOfYear = new Date(today.getFullYear(), 0, spendDay);
const d = Math.ceil((today.valueOf() - firstDayOfYear.valueOf()) / 86400000);
return Math.ceil(d / 7);
}
网友评论