ISO 8601 Date JS Interpretation Difference - IE/FF versus Chrome

后端 未结 2 1496
滥情空心
滥情空心 2021-01-15 01:52

Why do IE/FF and Chrome javascript engines differ on how to interpret this Date format (YYYY-MM-DDTHH:mm:ss.fff) without the timezone designator?

2条回答
  •  耶瑟儿~
    2021-01-15 02:08

    ES5 says that ISO 8601 format dates without a time zone should be treated as local(that interpretation has since been revised), but the ed. 6 draft says to treat them as UTC. Some script engines have implemented ed. 6, some ES5 and the rest neither.

    The ed. 6 (and later) aren't consistent with the ISO 8601 specification.

    The bottom line is don't use Date.parse (or pass strings to the Date constructor), manually parse date strings.

提交回复
热议问题