I get JSON from a server and parse it to an array.
The date.month propery is “03”, this is then added to a Date() object var date = new Date(year, month, day);
I convert the Date() object with date.toLocaleDateString()and the output in the iOS simulator is “April 5, 2012”.
How can this be?!?!?!
JavaScript and JSON source is here: http://developer.appcelerator.com/question/133958/month-of-date-object-is-3-but-tolocaledatestring-says-april
JavaScript Date objects track months as 0 through 11. January is 0, in other words, so April is 3. If your server-side code thinks months are 1 through 12, you just subtract one when making a JavaScript Date.