From: http://blog.csdn.net/sproy/article/details/6505144
The new date ("xxxx/XX/xx") Construction Method in Javascript has a wonderful effect. When you input "xxxx/XX/0" (0) the date obtained is the last day of the previous month of the month (the maximum value of the Month of "XX" is 69. If "" is input ", "" is displayed ". The biggest benefit is that when you input "xxxx/3/0", you will get the last day of January 1, February, xxxx, And it will automatically determine whether the current year is a leap year to return 28 or 29, you don't have to judge it by yourself. It's too convenient !! Therefore, if we want to select the year and the number of days of the month, we only need
VaR d = new date ("Select Year/select month + 1/0 ");
Alert (D. getdate ());
The getdaysinonemonth (year, month) method written in Javascript is as follows:
Function getdaysinonemonth (year, month) {month = parseint (month, 10) + 1; var d = new date (year + "/" + month + "/0 "); return D. getdate ();}
Note: My tests show that Google ChromeThis featureNot supported. The result is Nan. Compatibility problems!
You can try other methods to obtain the total number of days in a month.