Number of days in any month
date, javascript
Solution
function getDaysInMonth(m, y) {
return /8|3|5|10/.test(--m)?30:m==1?(!(y%4)&&y%100)||!(y%400)?29:28:31;
}
Problem
How can I write a JavaScript function that accepts a number from 1 - 12 representing the months of the year, and then returns the number of days in that month?
Related problems
- JavaScript calculate the day of the year (1 - 366)
- What is the best way to determine the number of days in a month with JavaScript?
- Get number days in a specified month using JavaScript?
- javascript to find leap year
- How to find leap year programmatically in C
- Leap year check using bitwise operators (amazing speed)
- What is the best way to determine the number of days in a month with JavaScript?