/*
获取当前日期是今年的第几周(无参数)
*/
function getYearWeek() {
var date = new Date();
var startDate = new Date(date.getFullYear(), 0, 1);
var dayOfWeek = startDate.getDay() || 7;
startDate.setDate(startDate.getDate() + (8 - dayOfWeek));
var daysSinceStart = Math.ceil((date - startDate) / 86400000);
var weekNumber = Math.ceil(daysSinceStart / 7) + 1;
return weekNumber;
}
开袋即食
该方案,1月1日所在周,会被视为第一周。
[泛微EC9] 公式:获取当前日期是今年的第几周 by https://oneszhang.com/archives/96.html