Tip: Date Constructor

[darron schall] The documentation for the Date constructor lists the values that you’re allowed to use when constructing a new Date instance. For the values of month and date, the valid range of values is limited to a small subset of positive integers. The month value can be 0-11 (0 = Jan, …, 11 = Dec), and the date value can be 1-31, depending on the number of days in the month.

What the documentation doesn’t tell you, however, is that you can pass pretty much any number for month and day, and still get a valid date back. This is really useful when trying to figure out some specific date values…

[ Read Original Post ]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: