According to MDN, new Date()
supports ISO 8601 encoded datetime strings. They mention that different browsers have inconsistent behaviour regarding the time zone, which I have observed. Other questions on this topic recommend using a parsing library.
However, ISO 8601 supports specifying that the time is UTC with a Z
at the end of the string. I have tested the code
new Date("2017-05-31T10:20:46.085755Z")
in Chrome 58, Firefox 43, Safari 9, and IE 11, and all of them correctly parse the date as UTC.
My date string is always in this exact format. So are there any browsers where this doesn't work? If the built-in function works for my use case, I would much rather not use a library.