Guidance

Formatting dates and times in data

Updated 9 August 2022

Use ISO 8601:2004 to represent dates and times in a machine-readable format in government systems.

1. Summary of the standard’s use for government

Use the ISO 8601 standard for machine-readable dates and times in:

  • APIs
  • data for transferring between systems
  • date sorting, for example at the start of filenames

This standard does not apply when human readability is the main concern. For example, dates and times added within the text of a document. The GOV.UK Design System has guidance on using dates in digital services.

This profile uses the 2004 version of the standard as it still meets the government’s needs.

The government chooses standards using the open standards approval process and the Open Standards Board has final approval. Read more about the approval process for selecting ISO 8601.

2. How this standard meets user needs

Users of this standard include:

  • publishers of government data
  • archivists
  • data scientists
  • data analysts
  • developers

Using the ISO 8601 standard means you’ll have:

  • more consistency in how your systems format data
  • the flexibility to choose how precise you make the date and time
  • an easier way to sort documents by date and filename
  • improved ability to exchange data internationally, without issues with time zones and date formats

The ISO standard documentation and its BSI equivalent are not free of charge. There are other profiles available for this standard which are free of charge including:

3. How to use the standard

Use the ISO 8601 format to the level of accuracy you need when you’re recording or exchanging a date, or date and time, in a system. The minimum level of accuracy for this standard is four digits representing a year.

List date and time elements in descending order of size (years, months, days, hours, minutes, seconds, milliseconds and microseconds). If you’re using ‘time’, separate it from the ‘date’ with ‘T’, use the 24-hour format and a colon to separate hours and minutes. You can also separate each value with hyphens to increase readability. For example, YYYY-MM-DD-THH:MM-SS. You can refer to midnight as either 00:00 or 24:00 so your documentation should be clear whether you’re referring to the start or end of the day.

This profile assumes that you’re using local time. You can add a Coordinated Universal Time (UTC) offset. For example, 2017-05-16T10:30:56+01:00 is 16 May 2017 10:30 and 56 seconds with an offset showing British summer time (BST), one hour ahead of UTC.

ISO 8601 is also compatible with other date standards such as:

  • RFC 3339, which simplifies ISO 8601 for use in internet protocols by leaving out infrequently used levels of accuracy
  • W3C date and time format, which is an ISO 8601 profile written to simplify its use in WWW standards

ISO 8601 is also used in the following open standards for government: