HomeArticlesFAQsXREFGamesSoftwareInstantBooksBBSAboutFOLDOCRFCsFeedbackSearchSite-Map
logo

Q533 How can I calculate the number of days in the current month?

You are here: irt.org | FAQ | JavaScript | Date | Q533 [ previous next ]

The following little gem was provided by Paul Bennett. At first look it looks too simple, but on closer investigation it is a pretty clever piece of code:

function days_in_month (year, month) {
     return 32 - new Date(year, month, 32).getDate();
}

Feedback on 'Q533 How can I calculate the number of days in the current month?'

©2011 Martin Webb