html中js通过指定的年月获取该月的天数

由于2015年是平年, 所以2月份是28天。故下面弹出的数字是28

<script>

    alert(GetLastDay('2015', '2'));

    function GetLastDay(year, month) {
        var date = new Date(year, month, 1),
        lastDay = new Date(date.getTime() - 864e5).getDate();

        //alert(date.getTime());   
        return lastDay;
    }

script>

你可能感兴趣的:(html中js通过指定的年月获取该月的天数)