根據年月日,算出在當前月的第幾周


最近有一個需求,根據年月日,比如:20191111,算出在11月的第幾周

定義方法

getMonthWeek(a, b, c) {
let date = new Date(a, parseInt(b) - 1, c);
let w = date.getDay();
let d = date.getDate();
if(w == 0){
w=7;
}
var config = {
getMonth: date.getMonth()+1,
getYear: date.getFullYear(),
getWeek: Math.ceil((d + 6 - w) / 7),
}
return config;
},

獲取具體是當月的第幾周
console.log(this.getMonthWeek('2019', '11', '11').getWeek)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM