Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  21] [ 6]  / answers: 1 / hits: 18484  / 15 Years ago, wed, january 6, 2010, 12:00:00

The string can be got by getFullYear and so on.



Can it be done reversely?


More From » date

 Answers
14

Replace - by / and JavaScript can parse it. Stupid mistake in JS specification (ISO date/time standard is very clear that - is correct)



var str = 2010-1-10;
alert(Date.parse(str.replace(/-/g,/)));


Try pasting it in your browser: javascript:alert(Date.parse(2010-01-01.replace(/-/g,/)));


[#97910] Sunday, January 3, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cristinadomoniquel

Total Points: 320
Total Questions: 94
Total Answers: 94

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
;