1. js获取某年某月的天数
实现代码
/**
* 获取某年某月的天数
* @param {Number} year 年
* @param {Number} month 月份
*/
function getDays(year, month) {
return (new Date(year, month, 0)).getDate();
}
console.log(getDays(2019, 9));//30代码解释
new Date(year, month, day);new Date(2019,9,0)new Date(2019,8,30)//2019-09-30Last updated
Was this helpful?