0
var d = new Date("2016-07-28T11:19:50.167");
var n = d.toISOString();

If in firefox, the result is "2016-07-28T17:19:50.167Z", but chrome doesn't work only if change input to "2016-07-28 11:19:50.167 PST", and the result is also different "2016-07-28T18:19:50.167Z", anybody know this?

nnnnnn
  • 147,572
  • 30
  • 200
  • 241
Catheryan
  • 111
  • 1
  • 1
  • 8
  • "but chrome doesn't work" --- it surely *works* here. – zerkms Aug 02 '16 at 01:24
  • the difference in output seems to be a summertime difference? as far as parsing input, yeah, thank you big three browsers for only having one common text format for date, that is probably the least useful – Jaromanda X Aug 02 '16 at 01:43
  • 1
    actually, without the Z suffix, firefox treats `2016-07-28T11:19:50.167` as local time, whereas chrome treats it as UTC – Jaromanda X Aug 02 '16 at 01:45
  • Yet again, parsing of strings using the Date constructor fails. Just don't to it, ever. **Always** manually parse the string. Use a library, write a small function, whatever, but **do not use the Date constructor** (or Date.parse, they are equivalent for parsing). – RobG Aug 02 '16 at 03:55
  • I've marked this as a duplicate because the issue isn't with *toISOString*, it's with parsing using the Date constructor. The duplicate answer shows why that's a bad idea. – RobG Aug 02 '16 at 03:57

0 Answers0