How can I convert dd.mm.yyyy format date to yyyy-mm-dd format in JavaScript?
Here is an example:
30.01.2010
to
2010-01-30
Meaning convert d.m.Y to Y-m-d. I know how to do this in PHP but I need it in JavaScript.
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.
Datejs can parse that. The code is at http://datejs.googlecode.com/files/date.js
EDIT: It is not safe to left date.js determine the format string automatically. I made the mistake of not testing with a day <= 12 (duh). You should use:
or
depending on whether you want to allow single digit days.