Javascript: calculate number of days in month for a given year
问题 I have a HTML page with 3 dropdowns for the month, day and year and I was wondering if there was a way to populate the month drop down properly depending on the month and year. I haven't done this before on the client side, but it looks like a lot of controls like the jQuery DatePicker are doing that behind the scenes. 回答1: You can play with date objects: var monthStart = new Date(year, month, 1); var monthEnd = new Date(year, month + 1, 1); var monthLength = (monthEnd - monthStart) / (1000 *