ISO 8601 standard

Christian Baghai
5 min readJan 30, 2023

--

Photo by Agê Barros on Unsplash

ISO 8601 is an international standard for representing date and time data in a clear, unambiguous format. It covers the Gregorian calendar, 24-hour timekeeping system, time intervals, and combinations of these. The standard requires the use of numerals and specific characters, and prohibits the use of words or images without numerical meaning. The greatest temporal term is placed at the left and successively lesser terms to the right. The standard does not assign specific meaning to elements, which depends on context.

The first edition of ISO 8601 was published in 1988 and replaced multiple older ISO standards on date and time notation. It was updated in 2000, 2004, and 2019, with the fourth revision (ISO 8601–1:2019) representing updated contents of the previous standard and the new ISO 8601–2:2019 defining various extensions. An amendment was published in 2022, introducing minor technical clarifications and reintroducing the “24:00:00” format to refer to the end of a calendar day. ISO 8601 was prepared by ISO Technical Committee TC 154.

ISO 8601 provides a standardized and unambiguous method for representing dates and times, making it easier to communicate and exchange such data across different countries and time zones. The standard follows a most-to-least-significant order, with values ordered from year to fraction of a second. Representations can be done in either a basic format or an extended format, with the latter being preferred in plain text communication. Reduced precision is also supported by the standard by dropping values from the least to the most significant. The standard allows for the addition of a decimal fraction to the smallest time value in the representation if needed.

ISO 8601 is an international standard for the representation of dates and time, including the Gregorian calendar. The minimum representation of the year requires four digits [YYYY] to avoid the year 2000 problem, representing years from 0000 to 9999 with year 0000 equal to 1 BC. The standard also allows for expanded year representation [±YYYYY] for years before 0000 or after 9999, by agreement between the sender and the receiver, with a + or — sign prefix. Calendar dates are represented in the form YYYY-MM-DD or YYYYMMDD. Reduced precision representation is also allowed, with YYYY-MM or simply YYYY to represent a year, decade, or century. The week date representation is in the format YYYY-Www or YYYYWww, where Www is the week number, and YYYYWww-D or YYYYWwwD, where D is the weekday number. The ISO week-numbering year starts with the first Monday of the year.

ISO 8601 specifies the standard representation of time and date-time values. It uses the 24-hour clock system and the basic format for time is “T[hh][mm][ss]” or the extended format is “T[hh]:[mm]:[ss]”. The “T” represents time, while [hh], [mm] and [ss] represent zero-padded hour, minute, and second values respectively. Time and date-time values can be represented in various levels of precision by omitting the seconds, minutes and seconds, or the minutes, as needed. The standard allows for adding a decimal fraction to the lowest order time element for increased precision. Time zones can be represented as local time, UTC, or as an offset from UTC using designated notations. If no UTC relation information is given, the time is assumed to be in local time. ISO 8601 uses the letter “Z” to represent UTC.

The UTC (Coordinated Universal Time) offset is a way of representing the difference between a local time and UTC time. UTC offsets can be positive or negative, depending on whether the local time is ahead or behind UTC. The UTC offset is expressed as a ±hh:mm or ±hhmm or ±hh, where hh represents hours and mm represents minutes. A minus sign is used to represent a negative UTC offset, and a plus sign is used to represent a positive offset. The UTC offset of +00:00 (also expressed as “Z”) represents UTC time itself. To calculate UTC time, one must subtract the UTC offset from the local time. The representation of UTC offsets follows the ISO 8601 standard, with certain exceptions in other specifications such as RFC 3339.

In ISO 8601, a single point in time can be represented by combining a complete date expression and a valid time expression separated by the letter “T”. The time zone designator, if required, follows the combined date and time. The format used for both the date and time parts can be either basic or extended, but they must be the same format. The date expression can be represented in calendar, week, or ordinal format and must have a complete representation. The time expression may use a specified reduced precision format. In ISO 8601:2004, omitting the “T” character was allowed but this provision was removed in ISO 8601–1:2019. Using characters like space to separate date and time parts is not allowed in ISO 8601 but is allowed in its profile RFC 3339.

Duration is a representation of the amount of time in a time interval using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. The capital letters P, Y, M, W, D, T, H, M, and S represent the date and time elements (period, year, month, week, day, time, hour, minute, second respectively). The value of each element is preceded by its designator. Leading zeros are not required. The format can be reduced to exclude elements with a value of 0. A decimal fraction can also be used for values less than 1. A different format based on combined date and time representations may also be used by agreement between parties. The duration format is ambiguous but becomes clear when used in a time interval.

In short, a time interval is the duration between two points in time. It can be expressed in 4 ways: Start and End, Start and Duration, Duration and End, or Duration only. ISO 8601–1:2019 standard provides a way to express time intervals using date and time representations. The standard allows for concise representations with missing elements assumed to be the same as the start value, including time zone. The precision of the representation can be increased by adding more time elements to the representation.

In ISO 8601, repeating intervals are expressed by adding “R[n]/” before the interval expression. [n] is the number of repetitions, where -1 means an unbounded number of repetitions and 0 means no repetition. The start of the interval is specified using forms 1 and 2, while the end of the interval is specified using form 3. For example, to express a repeating interval of “P1Y2M10DT2H30M” five times starting at “2008–03–01T13:00:00Z”, the expression would be “R5/2008–03–01T13:00:00Z/P1Y2M10DT2H30M”.

--

--