Tip: Date Constructor
January 2, 2007 Leave a comment
[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…