Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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();
}

©2018 Martin Webb