I have to parse a date string that looks like 20191128T000658Z
into a JavaScript Date Object. How can I do this without having to parse the string myself?
Asked
Active
Viewed 27 times
0

phoebus
- 1,280
- 1
- 16
- 36
-
4I personally recommend to use https://momentjs.com/ as date are generally a mess to manage, and moment do everything greatly – Crocsx Nov 28 '19 at 02:42
-
1P.s. `console.log( new Date( "20191128T000658Z".replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/, "$1-$2-$3T$4:$5:$6") ) );` — It doesn't seem a big problem) – OPTIMUS PRIME Nov 28 '19 at 02:49
-
@OPTIMUSPRIME—that would be "parsing the string myself". ;-) – RobG Nov 28 '19 at 03:25
-
Also see [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – RobG Nov 28 '19 at 03:29