Skip to content

Instantly share code, notes, and snippets.

@krunkosaurus
Created September 6, 2012 22:14
Show Gist options
  • Save krunkosaurus/3660778 to your computer and use it in GitHub Desktop.
Save krunkosaurus/3660778 to your computer and use it in GitHub Desktop.
Get days of a month of a year.
// 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