What is simplified in ECMAScript 5 date format compared to ISO 8601

ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 Extended Format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ
— https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15

So what exactly is the difference between the two formats? What do I have to be careful about? I noticed that ISO 8601 states that the T can be substituted by a space. What else is "simplified"?

To be very specific: This question is about the standard. Browser behavior is interesting, but not the main focus of this question.


ISO 8601 defines lots of different formats for a date and time, like:

  • extended (same used by ECMA): YYYY-MM-DDTHH:mm:ss.sssZ
  • basic (same as above, but without - and : separators): YYYYMMDDTHHmmss.sssZ
  • And also the variations: just the date, just the time and with or without offset. If a date uses one of the above (basic or extended), the time must use the same.

    And it also allows another formats for the date (not used by ECMA):

  • "incomplete" dates:
  • only the year: YYYY , or the expanded version with a + or - signal before the number
  • just year and month: YYYY-MM
  • just month and day: --MM-DD
  • week dates: YYYY-Www or YYYY-Www-D . Www is the week number (an uppercase W followed by 2 digits), but YYYY in this case is the ISO week-numbering year - quoting wikipedia:
  • The ISO week-numbering year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year (hence without overlap or gap). It consists of 52 or 53 full weeks. The first ISO week of a year may have up to three days that are actually in the Gregorian calendar year that is ending; if three, they are Friday, Saturday, and Sunday. Similarly, the last ISO week of a year may have up to three days that are actually in the Gregorian calendar year that is starting; if three, they are Monday, Tuesday and Wednesday. The Thursday of each ISO week is always in the Gregorian calendar year denoted by the ISO week-numbering year.

  • ordinal dates: YYYY-DDD ( year and day of the year ).
    Example: 2017-02-01 is the same as 2017-032 ( February 1st is the 32th day of the year ).
  • The week and ordinal formats above can also be used with a time.
    Example: 2017-02-01T10:00 and 2017-032T10:00 are both valid (and equivalent).

    ECMA simplifies it by allowing only YYYY-MM-DDTHH:mm:ss.sssZ . It also allows extended years (with 6 digits and a signal), but keeping the same format for the other fields.


    ISO 8601 also defines another concepts (Durations and Time Intervals). Although they're both related to dates and times, they're not the same thing: a duration is an "amount of time" (like "2 days, 4 hours and 5 minutes") and an interval is the "intervening time between two time points" (with start and end dates).


    ISO 8601 is a standard for a whole range of time and date formats, including:

  • Date
  • Time of day
  • Coordinated universal time (UTC)
  • Local time with offset to UTC
  • Date and time
  • Time intervals
  • Recurring time intervals
  • The ECMA-262 specification (20.3.1.16 in the 2017 version) only implements the date and time.

    链接地址: http://www.djcxy.com/p/35116.html

    上一篇: 在没有苹果开发者计划或越狱的情况下在设备上测试iOS应用

    下一篇: 与ISO 8601相比,ECMAScript 5日期格式简化了什么