# ISO 8601

Key: `datetime.timestamp.iso_8601`

Standard international datetime format with UTC indicator. The most widely used machine-readable datetime format.

Page: <https://meridian.online/docs/projects/finetype/types/datetime/timestamp/iso_8601>

Format: `%Y-%m-%dT%H:%M:%SZ`

Alternative format: `%Y-%m-%dT%H:%M:%S.%gZ`

Samples: `2024-01-15T10:30:00Z`, `2019-12-31T23:59:59Z`, `2023-06-01T00:00:00Z`

## Background

### Origin

ISO 8601 is an international standard covering the worldwide exchange and communication of date and time-related data.[[1]](https://en.wikipedia.org/wiki/ISO_8601) The first edition of ISO 8601 was published as ISO 8601:1988 in June 1988.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601:1988 unified and replaced a number of older ISO standards on various aspects of date and time notation.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601-1:2019 and ISO 8601-2:2019 superseded the third edition, ISO 8601:2004, on 25 February 2019.[[1]](https://en.wikipedia.org/wiki/ISO_8601) All editions and parts of ISO 8601 were prepared by ISO Technical Committee TC 154.[[1]](https://en.wikipedia.org/wiki/ISO_8601) In ISO 8601, a Z written directly after a time is the zone designator for the zero UTC offset.[[1]](https://en.wikipedia.org/wiki/ISO_8601) RFC 3339 notes that the Z suffix is often spoken "Zulu", from the ICAO phonetic alphabet representation of the letter.[[2]](https://www.rfc-editor.org/rfc/rfc3339)

The exact shape of this type, a T between date and time and a trailing Z, is easiest to read in two short profiles of ISO 8601 rather than in the standard itself. (Meridian's view) The W3C note Date and Time Formats is a submission to W3C from Reuters Limited.[[3]](https://www.w3.org/TR/NOTE-datetime) The W3C note Date and Time Formats was written by Misha Wolf and Charles Wicksteed.[[3]](https://www.w3.org/TR/NOTE-datetime) The W3C note Date and Time Formats was submitted to W3C on 15 September 1997.[[3]](https://www.w3.org/TR/NOTE-datetime) The W3C note Date and Time Formats restricts ISO 8601 to a small number of formats to reduce the scope for error and the complexity of software.[[3]](https://www.w3.org/TR/NOTE-datetime) The W3C note expresses the year as four digits in all cases, because ISO 8601 allows the century to be omitted from years.[[3]](https://www.w3.org/TR/NOTE-datetime) The W3C note's format for a complete date plus hours, minutes and seconds is YYYY-MM-DDThh:mm:ssTZD, where the time zone designator is Z, +hh:mm or -hh:mm.[[3]](https://www.w3.org/TR/NOTE-datetime) RFC 3339, Date and Time on the Internet: Timestamps, was written by G. Klyne and C. Newman and is dated July 2002.[[2]](https://www.rfc-editor.org/rfc/rfc3339) RFC 3339 defines a profile of ISO 8601 that should be used in new protocols on the Internet.[[2]](https://www.rfc-editor.org/rfc/rfc3339) In RFC 3339's grammar, the time offset is either the letter Z or a plus or minus sign followed by hours and minutes.[[2]](https://www.rfc-editor.org/rfc/rfc3339) RFC 3339 gives 1985-04-12T23:20:50.52Z as an example of its Internet date/time format, representing a time in UTC.[[2]](https://www.rfc-editor.org/rfc/rfc3339)

### Use

MDN documents the output of JavaScript's Date.prototype.toISOString() as always 24 or 27 characters long, in the form YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ.[[4]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) MDN says the time zone of toISOString() output is always UTC, as denoted by the suffix Z.[[4]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)

Python's documentation shows datetime.fromisoformat('2011-11-04T00:05:23Z') returning a datetime whose tzinfo is datetime.timezone.utc.[[5]](https://docs.python.org/3/library/datetime.html) Python's documentation says datetime.fromisoformat() changed in version 3.11, and previously supported only formats that date.isoformat() or datetime.isoformat() could emit.[[5]](https://docs.python.org/3/library/datetime.html) Check which Python version a pipeline runs on before relying on fromisoformat() for these strings. (Meridian's view) Python's documentation says that when the %z directive is given to strptime(), providing 'Z' is identical to '+00:00'.[[5]](https://docs.python.org/3/library/datetime.html)

RFC 3339 notes that the T and Z characters may alternatively be written in lower case as t and z.[[2]](https://www.rfc-editor.org/rfc/rfc3339) RFC 3339 says applications that generate its format should use upper case letters.[[2]](https://www.rfc-editor.org/rfc/rfc3339) RFC 3339 lets applications separate the full date and full time with a space character for the sake of readability.[[2]](https://www.rfc-editor.org/rfc/rfc3339) Wikipedia's article on ISO 8601 says separating the date and time parts with a space is not allowed in ISO 8601 itself.[[1]](https://en.wikipedia.org/wiki/ISO_8601) Values such as 2024-01-15 10:30:00Z and 2024-01-15T10:30:00Z can sit side by side in one file, so normalise the separator and the letter case before you compare or deduplicate. (Meridian's view)

RFC 3339 says timestamps in the same time zone, written with the same zone string and the same number of fractional second digits, can be sorted as strings into time order.[[2]](https://www.rfc-editor.org/rfc/rfc3339) Before sorting these timestamps as text, check that every value uses the same zone string and the same number of fractional digits. (Meridian's view) RFC 3339 gives 1990-12-31T23:59:60Z as its example of the leap second inserted at the end of 1990.[[2]](https://www.rfc-editor.org/rfc/rfc3339)

### Where you'll meet it

GitHub's REST API documentation says all timestamps return in UTC time, ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.[[6]](https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api)

## Sources

1. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) — secondary source
2. [RFC 3339: Date and Time on the Internet: Timestamps](https://www.rfc-editor.org/rfc/rfc3339) — standard
3. [Date and Time Formats](https://www.w3.org/TR/NOTE-datetime) — standard
4. [Date.prototype.toISOString() - JavaScript \| MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) — documentation
5. [datetime — Basic date and time types](https://docs.python.org/3/library/datetime.html) — documentation
6. [Getting started with the REST API](https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api) — organisation
