js判断哪个月有多少天

    技术2022-07-10  107

    这里的2月当28天算,不判断平年闰年,如想加上平年闰年,请看后面的博客

    <script> var a = parseInt(Math.random() * 12 + 1); switch (a) { case 1: alert(a + "月为31天"); break; case 2: alert(a + "月为28天"); break; case 3: alert(a + "月为31天"); break; case 4: alert(a + "月为30天"); break; case 5: alert(a + "月为31天"); break; case 6: alert(a + "月为30天"); break; case 7: alert(a + "月为31天"); break; case 8: alert(a + "月为31天"); break; case 9: alert(a + "月为30天"); break; case 10: alert(a + "月为31天"); break; case 11: alert(a + "月为30天"); break; case 12: alert(a + "月为31天"); break; default: alert("不正确的月份") break; } </script>
    Processed: 0.030, SQL: 9