My fiddle here is returning 0 for December
var exploded = "2011-12-25".split('-');
var d = new Date(exploded[0], exploded[1], exploded[2]);
document.write("year"+d.getUTCFullYear()+ " month"+d.getUTCMonth()+" day"+d.getUTCDate());
Why is this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this is the other way around: you are defining date as if it was in January.
See the documentation on
Date():You provided
12, so it was treated as0(January).If you need a proof, see modified version of the script, showing the whole date and time.