/**
* 获取某年某月天数
* @param {Date} date 年月 PS: 2022-03
*/
const getMonthDay = (date) => {
let year = Number(date.slice(0, 4))
let month = Number(date.slice(5, 7))
let days = new Date(year, month, 0).getDate()
return days
}
getMonthDay('2022-03') // 31
getMonthDay('2022-02-17 13:28:01') // 28