函数
function _getMonthWeek(theDate){
let currentDay = new Date(theDate);
console.info(currentDay); // 2019-05-07T07:36:00.883Z
// 获取该日期所在周的周六,如2019.5月的周六有4号、11号、18号、25号、31号
let theSaturday = currentDay.getDate() + (6 - currentDay.getDay());
console.info(theSaturday); // 11
return Math.ceil(theSaturday / 7);
}
调用
let now = new Date();
console.info(now); // 2019-05-07T07:36:00.883Z
console.info(_getMonthWeek(now)); // 2 即2019年5月的第二周