<script>
function getDateRange(year, month) {
var myDate1 = new Date(year, month, 1);
var myDate2 = new Date(year, month + 1, 0);
console.log(year + '年' + month + '月有' + myDate2.getDate() + '天')
}
getDateRange(2020, 1)
getDateRange(2000, 2)
</script>
05-22
778
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-10
2412
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-22