> > On Thu, Jun 30, 2011 at 2:38 PM, Sheldon Neilson <[email protected]>wrote: > > Anyone have some insight into why something like “new Date(2011, 6, 30) “ >> returns July? I noticed that the example at >> http://code.google.com/apis/chart/interactive/docs/reference.html#dateformatteris >> also a month ahead of itself... >> **** >> >> ** ** >> >> I’m including http://www.google.com/jsapi and the default table >> visualization package. >> >
> On Thu, Jun 30, 2011 at 5:42 AM, Peter van der Zee <[email protected]> > wrote: > >> Months in js are typically offset at zero when using the Date object. I > assume the google api used that too. So 0=jan, 5=june, 6=july. > Putting it more strongly, months in the Date object *do* start at zero: 0=Jan ... 11=Dec. But just to keep things confusing, years and days use the actual numbers, e.g. 2011 is 2011, and the first day of any month is 1. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date Here's a troubleshooting tip that may help with questions like this. In this case, it seemed that the Google date display function may be doing something strange. So a good test is to try some other, unrelated way of doing the same conversion. One easy way for this one is to simply enter the expression into the console in any of your favorite JS debuggers and see what it prints out: > new Date(2011, 6, 30) Sat Jul 30 2011 00:00:00 GMT-0700 (Pacific Daylight Time) > -Mike -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
