Inconsistant date parsing with missing timezone

后端 未结 2 789
抹茶落季
抹茶落季 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:43

    Standards clash. ISO 8601 states that:

    If no UTC relation information is given with a time representation, the time is assumed to be in local time.

    ECMA says:

    The value of an absent time zone offset is “Z”.

    Mozilla devs think that ISO takes precedence, Chrome folks seem to disagree.

    The current draft of ES6 says (under 20.3.1.15):

    If the time zone offset is absent, the date-time is interpreted as a local time.

    so Mozilla's implementation is (will be) correct.

提交回复
热议问题