new Date(year, month, 0).getDate()
// 获取月份的最后一天
let now = new Date()
let year = now.getFullYear()
let month = now.getMonth() - 1
function lastMonthday(year, month) {
let lastDay = new Date(year, month, 0).getDate()
console.log(lastDay);
return lastDay
}
lastMonthday(year, month)
lastMonthday('2023', '10')
标签:Date,月份,一天,month,获取,let,year,lastMonthday,lastDay
From: https://www.cnblogs.com/wszzj/p/17865924.html