ISO 8601
From Free net encyclopedia
2025-06-Template:CURRENTDAY2 18:07Z
ISO 8601, "Data elements and interchange formats – Information interchange – Representation of dates and times" is an international standard for date and time representations. The signature feature of the ISO 8601 format is that all values are organized from most to least significant. This leads to the increasingly familiar YYYY-MM-DD hh:mm:ss format seen in international forums.
Contents |
History of the standard
The first edition of the ISO 8601 standard was published in 1988 and unified and replaced a number of older ISO standards on various aspects of date and time notation: ISO 2014, 2015, 2711, 3307 and 4031. 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 Bigendian all-numeric date notation YYYY-MM-DD, the identification of days by ordinal dates was originally defined in ISO 2711, and the ISO week numbering system was introduced in ISO 2015.
General principles
Dates and times are self-contained, and do not rely on any external context for their values. They are entirely numerical in representation, although certain specialized formats use roman letters to label fields. Every ISO date has exactly one possible unambiguous interpretation. These properties allow them to be truly international, without reliance on regional conventions, such as the names of the days of the week.
Dates and times are organized from most to least significant digits. Each value (eg, year, month, day, time) has a fixed number of digits which must be padded with leading zeros. For instance, the American notation "4:30 am" would be written 04:30.
Representation can be done in one of two formats: A basic format with a minimal number of characters, or an extended format with separators to enhance human readability.[1] The standard permits a dash separator between date elements, and a colon between hours, minutes, and seconds. For example, 2006-01-06 may be written 20060106 without ambiguity. An optional "T" is suggested to separate date and time when those values will be stored in a single field, though another separator may be chosen with discretion. A space is a popular allowed human readable alternative.
Any number of fields may be dropped from any of the date and time formats, but the least significant fields must be dropped first. 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.
Finally, the standard supports the addition of a decimal fraction to the smallest time unit, where higher precision is needed.
Dates
The standard uses the Gregorian calendar, already the de facto standard of international trade, with the year numbering following astronomical year numbering. The standard acknowledges that other calendars may be used, such as the Julian calendar. It suggests that senders and receivers should explicitly agree when another calendar is used with the standard's notation. Dates are otherwise assumed to be Gregorian. In principle, dates should usually be converted to the proleptic Gregorian calendar to avoid possible confusion.
Years are always integers. Year 0001 corresponds to AD 1 (1 CE). The year before that is 0000, which corresponds to 1 BC (1 BCE). The year before that is -0001, which corresponds to 2 BC. This pattern continues. This system had already been used by astronomers, and may clarify the dispute about when a new century begins (see 20th century).
In some cases, years may be relaxed to fewer than four digits. However, the rules for this vary depending on what other information is being carried and if it will make the interpretation ambiguous. For instance, the date 2006-01-09 could be written 060109, but the month 2006-01 could only be shortened as -0601 (note the hyphen). Years can also be expanded to greater than four digits, though this is practically domain specific—such as archeological and astronomical events.
ISO 8601 describes three date formats of general interest. These can be quickly distinguished by a one, two, or three digit day field.
Calendar date
YYYY–MM–DD |
Calendar dates are the form familiar to most people. As represented above, YYYY indicates a year with century, and a negative sign for years before 1 BCE. MM indicates the month of the year, 01 through 12. DD indicates the day of that month, from 01 through 31. For example, "April 5th, 1981" may be represented as 1981-04-05 in the extended format, or 19810405 in the basic format.
The standard allows for dates to be written with less precision. For example, you may write 1981-04 to mean "April, 1981". You may simply write 1981 to refer to that year.
The standard also allows for dates which include an implied element, such as an implied century. It is careful to emphasize the importance of clear communication between sender and receiver when implied elements are being used. It is a lack of such clarity that led to the year 2000 problem.
Week dates
YYYY–Www–D |
Week dates are a form more popular in manufacturing. As represented above, YYYY indicates a ISO year. The "W" is a literal roman character followed by ww which represents the week number from 01 through 52 or 53. The "D" represents the day of the week from 1 through 7, beginning with Monday and ending with Sunday. For example, 1981-04-05 is the 7th day of the 14th week of 1981, and would be written 1981-W14-7, or in its most compact form 81W147.
Week 01 is the week with the year's first Thursday in it. Or in other words, the first week with the majority (four or more) of its days in the starting year. 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. Weeks 01, 52 and 53 can thus include days from more than one year and, in most years, do so. For example, 2008-12-29 is written 2009-W01-1 and 2010-01-03 is written 2009-W53-7. The year given by the Week format is often called the ISO year (opposed to the Gregorian year used in Calendar dates).
Ordinal dates
YYYY–DDD |
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 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.
Further details about dates
The standard allows for expansion and truncation of the year, by agreement between sender and receiver. Truncation means the year may be written with two digits (optionally preceded by a hyphen) to represent a year in an implied century. Unfortunately, common practice is to use two digits for either a year in an implied modern century or in the first century (89 might be 89 or 1989). Expansion means that the year may be written with more than four digits, which addresses the year 10,000 problem, by allowing the standard to specify dates later than AD 10000 or earlier than 10001 BC. Note however that expansion and truncation introduce ambiguities if separators are not used. For instance 200406 could either mean the year 200406; June 2004; 6 April 20; or 6 April 2020. The ISO standard suggests that "provisions be made" to prevent such confusions.
For purposes of reference ISO 8601 assigns the number 1875 to the year in which the Convention du Mètre was signed in Paris.
Times
hh:mm:ss |
ISO 8601 uses the 24-hour clock system that is used by much of the world. The basic format is hhmmss and the extended format is hh:mm:ss. hh refers to an 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, hhmm, and hh are all used.
Fractions may also be used with all three of the time elements. These are indicated by using the decimal point (either a comma or dot). A fraction may only refer to the most precise component of a time representation — that is, to denote "14 hours, 30 and one half minutes", do not include a seconds figure. Represent it as 14:30.5 or 1430.5. The "." may be replaced with a "," depending on the local custom.
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 1981-04-05 24:00 is the same instant as 1981-04-06 00:00.
Time zones
<time>Z <time>±hh:mm:ss |
If no time zone information is given with a time, the time zone is assumed to be in some conventional local timezone. 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 timezones. It is usually preferable to indicate a time zone using the standard's notation.
UTC
If the time is in UTC, it is very easy to show this. Simply add a Z directly after the time, without a space. "09:30 UTC" is therefore represented as 09:30Z or 0930Z. "14:45:15 UTC" would be 14:45:15Z or 144515Z.
Other time zones
Other time zones are specified by their offset from UTC, in the format ±hh:mm, ±hhmm, or ±hh. So if the time being described is one hour ahead of UTC (such as the time in Berlin during the winter) the offset 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 offset is the actual offset from UTC, and doesn't include any information on daylight saving time. Times expressed in local time for a user in Chicago, Illinois 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. (It could also be expressed using a fraction of the hour, as 18.5Z.)
Combined representations
<date> <time> YYYY-MM-DD hh:mm:ss <date>T<time> YYYY-MM-DDThh:mm:ss YYYYMMDDThhmmss |
Combining date and time representations is quite simple. It is in the format of <date>T<time>. The <date> and <time> sections are any proper representation of the date and time created by following the standard. A common use could be YYYY-MM-DDThh:mm:ss±hh:mm. 1981-04-05T14:30:30-05:00, for example.
The standard allows the replacement of T with a space if no misunderstanding arises. This is commonly done for human communications. A date/time with timezone like 1981-04-05T14:30-05 would then be written as 1981-04-05 14:30-05.
Duration
PnYnMnDTnHnMnS |
Durations are represented by the format PnYnMnDTnHnMnS (nM may be replaced with nW 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.
Alternately, a format more similar to the combined representation may be used: PYYYY-MM-DDThh:mm:ss. To represent the same interval as above in this format, use P0003-06-04T12:30:00.
Time interval
<begin>/<end> <begin>/<duration> <duration>/<end> <duration> |
Time intervals specify an amount of time. They may be specified in four ways:
- Start and end, such as 2002-03-01T13:00:00Z/2003-05-11T15:30:00Z
- Start and duration, such as 2002-03-01T13:00:00Z/P1Y2M10DT2H30M
- Duration and end, such as P1Y2M10DT2H30M/2003-05-11T15:30:00Z
- Duration only, such as P1Y2M10DT2H30M
Of these, the first three require two separate values, separated by the interval designator, which is usually a forward slash "/". (The double hyphen (--) is permissible in some applications but is not preferred.) An example using the format from item #1 is 1981-04-05T14:30:30-05:00/2004-07-14T15:30:30-05:00. If any elements are missing from the second value, they are assumed to be the same as the first value, including time zone elements.
Repeating intervals
Repeating intervals are formed by adding Rn/ 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 2002-03-01T13:00:00Z, use R5/2002-03-01T13:00:00Z/P1Y2M10DT2H30M.
Usage
On the Internet, ISO 8601 is used by the W3C, defining a profile of the standard that restricts the supported formats to reduce the chance of error and the complexity of software. See also W3C link in External links, below.
ISO 8601 is referenced by several specifications, but not always is the full range of options of ISO 8601 used. E.g. the different EPG standards for TV, Digital Radio, etc. do use several formats to describe points in time and durations.
The ISO 8601 week date, as of 2006-01, already appears in its basic form on major brand commercial packaging in the US. Its appearance depends on the particular packaging, canning, or bottling plant more than any particular brand. The format is particularly useful for quality assurance, so that production errors can be readily traced to work weeks, and products can be correctly targeted for recall.
External links
- The ISO 8601 Date Format
- ISO 8601 summary by Markus Kuhn
- International Date Format Campaign
- ISO 8601 Implementation Around The World
- ISO 8601 discussion group at Yahoo!
- ISO 8601 section of Open Directory Project
- W3C
- Non-endorsed information
- Recommendations
- dateTime data type in XML Schema, which is based on a subset of ISO 8601
- RFC 3339, Date and Time on the Internet, 2002-July
- Purchase the ISO 8601:2004 standard (English, 33 pages, PDF, CHF 122)
- ISO 8601 draft copies in PDF format
- Current date in week date and ordinal date format
- The Mathematics of the ISO 8601 Calendar
- ISO 8601 - Converting and implementing
- A reference implementation in JavaScriptca:ISO 8601
de:ISO 8601 eo:ISO 8601 fr:ISO 8601 km:ISO 8601 la:ISO 8601 nl:ISO 8601 ja:ISO 8601 no:ISO 8601 pl:ISO 8601 sl:ISO 8601 fi:ISO 8601 sv:ISO 8601 zh:ISO 8601