admin管理员组

文章数量:1323330

Using Javascript how do I convert ISO string 2013-08-10T12:10:15.474Z into a date ()object. do not use moment

I want to end up with HH MM SS MM DD YYYY

date.parse converts the string into milliseconds since 1/1/70 That is not what I want.

Using Javascript how do I convert ISO string 2013-08-10T12:10:15.474Z into a date ()object. do not use moment

I want to end up with HH MM SS MM DD YYYY

date.parse converts the string into milliseconds since 1/1/70 That is not what I want.

Share edited Nov 3, 2017 at 2:19 Herbie asked Nov 3, 2017 at 1:50 HerbieHerbie 871 gold badge1 silver badge5 bronze badges 5
  • 1 What happened when you tried new Date('2013-08-10T12:10:15.474Z')? Or Date.parse()? – nnnnnn Commented Nov 3, 2017 at 1:51
  • What about using Date.parse('2013-08-10T12:10:15.474Z')? – m00n Commented Nov 3, 2017 at 1:54
  • 5 Possible duplicate of Change ISO Date String to Date Object - JavaScript – admcfajn Commented Nov 3, 2017 at 1:57
  • 1 Date.parse() does not return a date object... – dandavis Commented Nov 3, 2017 at 2:15
  • Regarding your edit, and the desired output format, if you just need a string in a different format and not a Date() object the easiest way is to do it all as string manipulation: a one-liner with the string .replace() method and a regex. – nnnnnn Commented Nov 3, 2017 at 2:30
Add a ment  | 

1 Answer 1

Reset to default 6

You can use new Date('2013-08-10T12:10:15.474Z') or Date.parse('2013-08-10T12:10:15.474Z').

本文标签: javascriptconvert ISO date time string into a Date() objectStack Overflow