当具体的每月天数,根据月份联动显示 ,则需要判断该月是大月,还是小月,是闰年还是平年,具体实现方法如下:
function DaysInMonthAndYear(year, month) {
month = parseInt(month, 10);
var temp = new Date(year, month, 0);
let n = +temp.getDate();
let dataTimes = [];
for (var i = 1; i < n + 1; i++) {
dataTimes.push(i);
}
return dataTimes;
}
console.log(DaysInMonthAndYear(2000, 2));
RoveCoder版权所有,转载请注明