Jump to content

ISO 8601

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Richardrw (talk | contribs) at 05:50, 22 February 2008 (New section- Scope and application of the standard (started)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

ISO 8601 is an international standard for date and time representations issued by the International Organization for Standardization (ISO). Specifically, the standard is titled, "Data elements and interchange formats — Information interchange — Representation of dates and times." The signature feature of ISO 8601 date and time representations is the ordering of date and time values from the most to the least significant or, in plain terms, from the largest (the year) to the smallest (the second).

Example date:
2024-10-18
Example separate date and time in UTC:
2024-10-18 04:18Z
Example combined date and time in UTC:
2024-10-18T04:18Z
Example date with week number:
Template:ISOWEEKDATE

History of the standard

The first edition of the ISO 8601 standard was published in 1988. It unified and replaced a number of older ISO standards on various aspects of date and time notation: ISO 2014, ISO 2015, ISO 2711, ISO 3307, and ISO 4031[1]. It has since then been superseded by a second edition in 2000 and finally the current third edition, ISO 8601:2004, published 2004-12-03.

ISO 2014 was the standard that originally introduced the big-endian all-numeric date notation [YYYY]-[MM]-[DD]. The ISO week numbering system was introduced in ISO 2015, and the identification of days by ordinal dates was originally defined in ISO 2711.

It is maintained by ISO/ITC 154.

Scope and application of the standard

The scope of the standard covers representations for dates, time of day, combined date and time of day, and time intervals. Dates can be represented in three forms: 1) year-month-day of month, 2) year-week number-day of week, and 3) year-day of year. Time of day is represented by using the 24-hour clock. Combined date and time is represented by merging both the date and time of day representations to denote a single time point. Time intervals are represented in a number of ways by using a combination of a start point, end point, duration, and context information.

The application of the standard is intended to be very broad. It applies to all written communications that contain dates, times, and time intervals regardless of the communication medium (printed, electronic, or hand written) or the location of the sender and receiver (either within an organization, between organizations, or across international boundaries). The application of the standard was never meant to be limited to dates and times processed and displayed by computers. It applies to all industries and all forms of human activity where accurate and unambiguous representations of dates, times, and time intervals are needed.

The standard does not cover worded dates, nor does it preclude the use of worded dates. Worded dates are specifically omitted from the standard mostly because their language dependency can impede international communication.

General principles

  • Date and time values are organized from the most to the least significant: year, month (or week), day, hour, minute, second, and fraction of second. The lexicographical order of the representation corresponds to chronological order, except for date representations involving negative years.
  • Each date and time value has a fixed number of digits that must be padded with leading zeros.
  • Representations can be done in one of two formats—a basic format with a minimal number of separators or an extended format with separators added to enhance human readability.[2] The separator used between date values (year, month, week, and day) is the hyphen, while the colon is used as the separator between time values (hours, minutes, and seconds). For example, the 6th day of the 1st month of the year 2009 may be written as "2009-01-06" in the extended format or simply as "20090106" in the basic format without ambiguity. The extended formats are preferred over the basic formats not only for human readability, but because some basic formats can appear to be ambiguous to those unfamiliar with the standard.
  • For reduced accuracy, any number of values may be dropped from any of the date and time representations, but in the order from the least to the most significant. For example, "2004-05" is a valid ISO 8601 date, which indicates the 5th month of the year 2004. This date will never represent the 5th day of some unknown month in 2004.
  • When higher precision is needed, the standard supports the addition of a decimal fraction to the smallest time value in the representation.

Dates

Template:CURRENTCALENDAR The standard uses the Gregorian calendar, which is the most widely used calendar in the world and is already the de facto standard of international trade.

As a point of interest, ISO 8601 fixes a reference calendar date to the Gregorian calendar of 1875-05-20 as the date the Convention du Mètre was signed in Paris. Among other things, this reference date allows ISO calendar dates to be converted to the Chronological Julian Day Numbers (CJDNs) for numeric date calculations with 1875-05-20 exactly equal to CJDN 2406029. However, ISO calendar dates before the Convention are still compatible with the Gregorian calendar back to the official introduction of the Gregorian calendar on 1582-10-15.

YYYY
±YYYYY

Years

ISO 8601 prescribes, as a minimum, a four-digit year [YYYY] to avoid the year 2000 problem.

To represent years before 0 or after 9999, the standard also permits the expansion of the year representation [±YYYYY], but only by prior agreement between the sender and the receiver.[3] An expanded year representation must have an agreed upon number of extra year digits beyond the four-digit minimum and is always prefixed with a + or − sign with the convention that year 0 is positive.

Calendar dates

YYYY-MM-DD or YYYYMMDD
YYYY-MM but not YYYYMM

Calendar date representations are the form familiar to most people. As shown in the box to the right, [YYYY] indicates a four-digit year. [MM] indicates a two-digit month of the year, 01 through 12. [DD] indicates a two-digit day of that month, from 01 through 31. For example, "the 5th of April 1981" may be represented as either "1981-04-05" in the extended format or "19810405" in the basic format.

The standard also allows for calendar dates to be written with reduced accuracy. For example, one may write "1981-04" to mean "1981 April", and one may simply write "1981" to refer to that year. Although the standard allows both the YYYYMMDD and YYYY-MM-DD formats for complete calendar date representations, if the day [DD] is omitted then only the YYYY-MM format is allowed. By disallowing dates of the form YYYYMM, the standard avoids confusion with the truncated representation YYMMDD (still often used).

Week dates

YYYY-Www or YYYYWww
YYYY-Www-D or YYYYWwwD

A week date specifies a so-called ISO year in the format [YYYY], a week number in the format [WW] prefixed by the letter 'W', and the weekday number, a digit [D] from 1 through 7, beginning with Monday and ending with Sunday. This form is popular in manufacturing.

Mutually equivalent definitions for week 01 are:

  • the week with the year's first Thursday in it
  • the week with 4 January in it
  • the first week with the majority (four or more) of its days in the starting year
  • the week starting with the Monday in the period 29 December - 4 January
  • If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year.

The week number can be described by counting the Thursdays: week 12 contains the 12th Thursday of the year.

The ISO 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 ISO year number deviates from the number of the normal year (Gregorian year) on, if applicable, a Friday, Saturday, and Sunday, or a Saturday and Sunday, or just a Sunday, at the start of the ordinary year (which are at the end of the previous ISO year) and a Monday, Tuesday and Wednesday, or a Monday and Tuesday, or just a Monday, at the end of the ordinary year (which are in week 01 of the next ISO year). For Thursdays the ISO year number is always equal to the ordinary year number.

Examples:

For an overview of week numbering systems see week number. The US system has weeks from Sunday through Saturday, and partial weeks at the beginning and the end of the year. An advantage is that no separate year numbering like the ISO year is needed, while correspondence of lexicographical order and chronological order is preserved.

Ordinal dates

YYYY-DDD or YYYYDDD

Ordinal dates are a simple form for times when the arbitrary nature of week and month definitions are more of an impediment than an aid, for instance, when comparing dates from different calendars. As represented above, [YYYY] indicates a year. [DDD] is the day of that year, from 001 through 365 (366 in leap years). For example, "1981-04-05" is also "1981-095".

This format has particular use for simple hardware systems that have need of a date system, but where including full calendar calculation software may be a significant nuisance. This system is frequently, though incorrectly, referred to as the Julian Date.

Times

hh:mm:ss or hhmmss
hh:mm or hhmm
hh

ISO 8601 uses the 24-hour clock system. The basic format is [hh][mm][ss] and the extended format is [hh]:[mm]:[ss]. [hh] refers to a zero-padded hour between 00 and 24, where 24 is only used to notate the midnight at the end of a calendar date. [mm] refers to a minute between 00 and 59. [ss] refers to a second between 00 and 59 (or 60 in the exceptional case of an added leap second). So a time might appear as "13:47:30" or "134730".

It is also acceptable to omit elements to reduce precision. [hh]:[mm], [hh][mm] and [hh] are all used.

Decimal fractions may also be used with any of the three time elements. These are indicated by using the decimal point (either a comma (which is preferred ISO 31) or dot). A fraction may only refer to the most precise component of a time representation. To denote "14 hours, 30 and one half minutes", do not include a seconds figure. Represent it as "14:30,5" or "1430,5".

Midnight is a special case and can be referred to as both "00:00" and "24:00". The notation "00:00" is used at the beginning of the day, and is the most frequently used one. At the end of a day use "24:00". Note that "2007-04-05T24:00" is the same instant as "2007-04-06T00:00" (see Combined representations below).

Time zones

or

If no time zone information is given with a time, the time zone is assumed to be in some conventional local time zone. While it may be safe to assume a local zone when used between two people in the same area, it is ambiguous when used in communication between multiple time zones. It is usually preferable to indicate a time zone (zone designator) using the standard’s notation.

UTC

If the time is in UTC, add a 'Z' directly after the time, without a space; 'Z' is the zone designator for zero offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".

UTC time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic alphabet word for 'Z'.

Other time zones

The zone designator for other time zones is specified by the offset from UTC in the format ±[hh]:[mm], ±[hh][mm] or ±[hh]. So if the time being described is one hour ahead of UTC (such as the time in Berlin during the winter), the zone designator would be "+01:00", "+0100", or simply "+01". This is appended to the time in the same way that 'Z' was above. Note that the zone designator is the actual offset from UTC and does not include any information on daylight saving time. The zone designator or UTC offset for a user in Chicago would be "-06:00" for the winter (Central Standard Time) and "-05:00" for the summer (Central Daylight Time). The following times all refer to the same moment: "18:30Z", "22:30+04", "1130-0700", and "15:00-03:30". Nautical time zone letters are not used with the exception of Z.

Time zone conversions

Conversion between time zones obeys the relationship

"time in zone A" - "UTC offset for zone A" = "time in zone B" - "UTC offset for zone B",

in which each side of the equation is equivalent to UTC.

Using the term "UTC offset" rather than zone designator as the standard does, the conversion equation can be rearranged to

"time in zone B" = "time in zone A" - "UTC offset for zone A" + "UTC offset for zone B".

For example, what time is it in Los Angeles when the New York Stock Exchange opens?

time in zone PST = 09:30 - (-05:00) + (-08:00) = 06:30

In Delhi, the New York Stock Exchange opens at

time in India zone = 09:30 - (-05:00) + (+5:30) = 20:00

Combined date and time representations

<date>T <date>T

Combining date and time representations to represent a single point in time (time point) is quite simple. It is in the format of <date>T

A combined date and time representation can be used to mark any type of event time such as an e-mail delivery, a financial transaction, the start of a medical treatment, or even a natural occurrence (like the summer solstice of 2009 shown above). Combined date and time representations are also used in conjunction with time intervals as discussed later in this article.

The date and time representations may appear in proximity to each other, often separated by a space or sometimes by other characters. In these cases they occupy two separate fields in a data system, rather than a single combined representation. This is usually done for human readability. Unlike the previous examples, "2007-04-05 14:30" is considered two separate, but acceptable, representations—one for date and the other for time. It is then left to the reader to interpret the two separate representations as meaning a single time point based on the context.

Durations

PnnYnnMnnDTnnHnnMnnS
PnnYnnWnnDTnnHnnMnnS
P<date>T

Durations are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S (or P[n]Y[n]W[n]DT[n]H[n]M[n]S to use the week format). In this representation replace [n] with the appropriate number for the element that follows it (leading zeros are optional but may clarify ambiguous durations). The capital letters ('P', 'Y', 'M', 'W', 'D', 'T', 'H', 'M' and 'S') are used as they are and not replaced. Thus "P3Y6M4DT12H30M0S" defines "a period of three years, six months, four days, twelve hours, thirty minutes, and zero seconds". Elements may be omitted if their value is zero. To resolve ambiguity, "P1M" is one month and "PT1M" is one minute. The smallest value used may also have a decimal fraction, as in "P0,5Y" to indicate half a year.

Sometimes ISO 8601 is called the "metric date format", but the chosen abbreviations in durations do not match common metric symbols (a, mon, d, h, min, s).

Alternately, a format more based on the combined representation may be used: P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]. To represent the same duration as above in this format, use "P0003-06-04T12:30:00".

Time intervals

<start>/<end>
<start>/<duration>
<duration>/<end>
<duration>

A time interval is the amount of intervening time between two time points. The amount of intervening time is expressed by a duration (as described in the previous section). The two time points (start and end) are expressed by either a combined date and time representation or just a date representation.

There are four ways to express a time interval:

  1. Start and end, such as "2007-03-01T13:00:00Z/2008-05-11T15:30:00Z"
  2. Start and duration, such as "2007-03-01T13:00:00Z/P1Y2M10DT2H30M"
  3. Duration and end, such as "P1Y2M10DT2H30M/2008-05-11T15:30:00Z"
  4. Duration only, such as "P1Y2M10DT2H30M", with additional context information

Of these, the first three require two values separated by an interval designator which is usually a solidus or forward slash "/". In certain applications, a double hyphen (--) can be used as a separator instead of a solidus (see Section 4.4.2 of the standard).

For <start>/<end> expressions, if any elements are missing from the end value, they are assumed to be the same as for the start value including the time zone. This feature of the standard allows for concise representations of time intervals. For example, the date of a two-hour meeting including the start and finish times could be simply shown as "2007-12-14T13:30/15:30", or the beginning and end dates of a monthly billing period as "2008-02-15/03-14".

If greater precision is desirable to represent the time interval, then more time elements can be added to the representation. An observation period that has a duration of approximately three days, for example, can be succinctly shown as "2007-11-13/15". If the exact start and end of the observation period need to be shown either for clarity or for measurement and recording purposes, the same time interval representation could be expanded to "2007-11-13T00:00/15T24:00".

Repeating intervals

Rnn/<interval>
R/<interval>

Repeating intervals are formed by adding "R[n]/" to the beginning of an interval expression, where 'R' is used as the letter itself and [n] is replaced by the number of repetitions. Leaving out the value for [n] means an unbounded number of repetitions. So, to repeat the interval of "P1Y2M10DT2H30M" five times starting at "2008-03-01T13:00:00Z", use "R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M".

Truncated representations

ISO 8601:2000 allowed truncation (by agreement), where leading components of a date or time are omitted. Notably, this allowed two-digit years to be used and the ambiguous formats YY-MM-DD and YYMMDD. This provision was removed in ISO 8601:2004.

Notes

  1. ^ Technical Committee ISO/TC 154, Processes, data elements and documents in commerce, industry and administration. (2004-12-01). "ISO 8601:2004(E)". ISO. Retrieved 2006-11-15. Annex A … From that concept representations of all other date and time values were logically derived; thus, ISO 2014, ISO 3307 and ISO 4031 have been superseded. … Identification of a particular date by means of ordinal dates (ISO 2711) and by means of the week numbering system (ISO 2015) were alternative methods that the basic concept of this International Standard could also encompass; thus, ISO 2015 and ISO 2711 have now been superseded. {{cite web}}: External link in |author= (help)CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link)
  2. ^ Numeric representation of Dates and Time
  3. ^ Technical Committee ISO/TC 154, Processes, data elements and documents in commerce, industry and administration. (2004-12-01). "ISO 8601:2004(E)". ISO. Retrieved 2006-11-15. 3.5 Expansion … By mutual agreement of the partners in information interchange, it is permitted to expand the component identifying the calendar year, which is otherwise limited to four digits. This enables reference to dates and times in calendar years outside the range supported by complete representations, i.e. before the start of the year [0000] or after the end of the year [9999]. {{cite web}}: External link in |author= (help)CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link)

See also

Implementations