Inconsistant date parsing with missing timezone

后端 未结 2 792
抹茶落季
抹茶落季 2021-01-06 18:05

In doing some testing I\'ve found inconsistant behavior between browsers with the following javascript

new Date(\"2013-09-10T08:00:00\").toString()
         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 18:35

    There are several questions on stackoverflow.com that address this issue. I gave a rather thorough explanation here if anyone reading this is interested in the browser-to-browser details.

    The bottom line though is, for now at least, you should either avoid the ISO 8601 format all together or ALWAYS include a timezone specifier when using it. And, never use the 'YYYY-MM-dd' format because it gets interpreted as a short version of ISO 8601 without a time zone specifier.

提交回复
热议问题