Quicktip: Nov. 31, 2007 == Dec. 1, 2007
This issue only manifested itself when the current date is the 31st day of the month and only caused display problem for months with less than 31 days.
What is going on?
Let's go over the "offending" code:
var today = new Date(); // new Date(2007, 9, 31);
This creates a new date object with Oct. 31, 2007 (which is today)
This sets the month to November
This shows an alert box with Dec 1, 2007
1. Set the day of the month before setting the month.
2. Create a new date object using appropriate parameters: new Date(2007, 10, 1);