Created
September 6, 2012 22:14
-
-
Save krunkosaurus/3660778 to your computer and use it in GitHub Desktop.
Get days of a month of a year.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arguments are NOT 0-based. | |
function getDaysOfMonth(yearInt, monthInt){ | |
return new Date(yearInt, monthInt, 0).getDate(); | |
} | |
// Days of month for February 2011 | |
getDaysOfMonth(2011, 2); | |
// 28 | |
// Days of month for February 2012 | |
getDaysOfMonth(2012, 2); | |
// 29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment