Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Date | Q533 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.