if dd = "2012-08-20 01:16:00";
converting this date to time-stamp (as in the following code)
var t = new Date(dd).getTime();
http://jsfiddle.net/userdude/DHxwR/
the result t = NaN why ?
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.
According to ECMA-262 (§15.9.1.15, Date Time String Format, page 169), the only date string format required to be accepted is:
where
Zis eitherZ(for UTC) or an offset consisting of either a+or a-followed byHH:mm. Any other formats that happen to be supported by a particular browser should not be relied upon, as continued support is not guaranteed.Therefore, replace the space with a
Tand append either aZ, or a fixed time zone offset before passing it to theDateconstructor. For example, if the date and time are in the UTC+8 zone:This will return the number of milliseconds from January 1, 1970, midnight UTC, to the date you have specified, treated as either universal time (if you appended
Z) or a time local to the fixed time zone offset that you specify.Please note that this will act differently in that the date is not simply treated as time local to the user’s system time zone as your question’s example does. However, I can’t think of a situation where doing that would be useful, because you’d get different results depending on the user’s configuration — but in reality, the time difference between two dates is always the same no matter where you are.