Skip to content

ISO 8601

ISO 8601 is an international standard for representing date and time in a machine-readable format. The standard was first published by the International Organization for Standardization (ISO).

1. Category

ISO 8601 standardized date format provides a clear and unambiguous way of representing dates that can be easily understood and interpreted by users worldwide.

1.1. UTC

Coordinated Universal Time (UTC) is the primary time standard used in ISO 8601 for timekeeping and data exchange. UTC is a time standard that is based on the International System of Units (SI) second, which is defined as the duration of 9,192,631,770 cycles of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom.

In ISO 8601, UTC is represented as Z (which stands for Zulu time) at the end of the time string, following the time offset, if present. For example, the time 12:30:00 PM UTC would be represented as 12:30:00Z in ISO 8601 format.

Using UTC in ISO 8601 ensures that the representation of time is standardized and easily understood across different languages and cultures, making it useful for international communication and data exchange.

1.2. Date

Represents a specific date in the format YYYY-MM-DD, where:

  • YYYY

    Represents the year with four digits.

  • MM

    Represents the month with two digits (01-12).

  • DD

    Represents the day with two digits (01-31).

1.3. Time

Represents a specific time in the format hh:mm:ss.sss, where:

  • hh

    Represents the hour with two digits (00-23).

  • mm

    Represents the minute with two digits (00-59).

  • ss

    Represents the second with two digits (00-59).

  • sss

    Represents the millisecond with three digits (000-999).

1.4. Date and Time

Represents a specific point in time in the format YYYY-MM-DDThh:mm:ss.sssZ, where:

  • YYYY

    Represents the year with four digits.

  • MM

    Represents the month with two digits (01-12).

  • DD

    Represents the day with two digits (01-31).

  • T

    Separates the date from the time.

  • hh

    Represents the hour with two digits (00-23).

  • mm

    Represents the minute with two digits (00-59).

  • ss

    Represents the second with two digits (00-59).

  • sss

    Represents the millisecond with three digits (000-999).

  • Z

    Represents the time zone in UTC (Coordinated Universal Time).

An example of the ISO 8601 format for April 23, 2023, at 10:30:45 AM in Eastern Standard Time (UTC-5) would be 2023-04-23T10:30:45.000-05:00.

1.5. Duration

Duration is used to represent the amount of time between two events or the duration of an event. The format for durations is P[n]Y[n]M[n]DT[n]H[n]M[n]S, where:

  • P

    Represents the duration designator, which indicates that this is a duration value.

  • n

    Represents the number of years (Y), months (M), days (D), hours (H), minutes (M), or seconds (S) in the duration. The number can be an integer or a decimal.

  • T

    Represents the time designator, which indicates that the time values (hours, minutes, seconds) follow the date values (years, months, days).

For example, a duration of 1 year, 2 months, 3 days, 4 hours, 5 minutes, and 6 seconds would be represented as follows:

P1Y2M3DT4H5M6S

Note that if any of the values are zero, they can be omitted. For example, a duration of 1 hour and 30 minutes would be represented as:

PT1H30M

1.6. Time Zone

The standardized format of time zones in ISO 8601 ensures that the representation of time zones is consistent and easily understood across different languages and cultures, making it useful for international communication and data exchange.

In ISO 8601, time zones are represented using the format ±hh:mm or ±hh, where:

  • ±

    The plus (+) or minus (-) sign indicates the direction of the offset from Coordinated Universal Time (UTC).

  • hh

    Represents the number of hours in the time zone offset, ranging from 00 to 14.

  • mm

    Represents the number of minutes in the time zone offset, ranging from 00 to 59.

For example, the time zone of Eastern Standard Time (EST) in the United States, which is 5 hours behind UTC, would be represented as -05:00 in ISO 8601 format. Similarly, the time zone of India Standard Time (IST), which is 5 hours and 30 minutes ahead of UTC, would be represented as +05:30.

1.7. Time Offset

In ISO 8601, time offsets are used to indicate the difference between Coordinated Universal Time (UTC) and the local time.

The standardized format of time offsets in ISO 8601 ensures that the representation of time differences between UTC and local time is consistent and easily understood across different languages and cultures

The time offset is represented as ±hh:mm, where:

  • ±

    The plus (+) or minus (-) sign indicates whether the local time is ahead of or behind UTC, respectively.

  • HH

    Represents the number of hours in the time offset, ranging from 00 to 14.

  • mm

    Represents the number of minutes in the time offset, ranging from 00 to 59.

For example, a time offset of 5 hours and 30 minutes behind UTC (i.e., India Standard Time) would be represented as UTC-05:30 in ISO 8601 format.

1.8. Time Interval

In ISO 8601, time intervals are represented using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S, where:

  • P

    Represents the duration designator and is always the first character of the string.

  • n

    Represents the number of years (Y), months (M), days (D), hours (H), minutes (M), or seconds (S) in the time interval.

For example, a time interval of 3 years, 2 months, and 15 days would be represented as P3Y2M15D in ISO 8601 format. Similarly, a time interval of 4 hours and 30 minutes would be represented as PT4H30M.

ISO 8601 also allows for the use of decimal fractions of a second in the time interval format. For example, a time interval of 1 minute and 30.5 seconds would be represented as PT1M30.5S.

The ISO 8601 time interval format is useful for representing durations, elapsed times, and intervals between two points in time. Its standardized format ensures that the representation of time intervals is unambiguous and easily understood across different languages and cultures.

1.9. Recurring Time Intervals

Represented as a combination of a start time, a duration, and a repetition rate. This format allows users to represent complex patterns of recurring time intervals in a standardized and unambiguous way.

The recurring time interval format follows the following syntax:

R[repetition]/[duration]/[start time]/[time interval]
  • Repetition

    This is represented as the letter R followed by the repetition rate in the form of an integer or a decimal number. For example, to represent an event that occurs every hour, the repetition would be R1.

  • Duration

    This is represented as the letter P followed by a time duration in the format of Thh:mm:ss.sss. For example, to represent an event that lasts for 30 minutes, the duration would be PT30M.

  • Start Time

    This is represented as a date and time in the format of YYYY-MM-DDThh:mm:ss.sss. This specifies the start time for the recurring time interval.

  • Time Interval

    This is represented as the letter P followed by a time duration in the format of Thh:mm:ss.sss. This specifies the interval between each recurrence of the event. For example, to represent an event that occurs every hour and lasts for 30 minutes, the time interval would be PT1H (i.e., one hour).

This format can be used to represent a wide range of recurring time intervals, from simple daily events to complex schedules that occur at irregular intervals. An example of a recurring time interval expression for an event that occurs every hour and lasts for 30 minutes, starting on April 23, 2023, at 12:00:00 PM UTC:

R/PT30M/2023-04-23T12:00:00Z/PT1H

2. Principles

ISO 8601 is based on several principles that aim to ensure that the date and time representation is standardized, unambiguous, and internationally recognized.

  • Complete representation

    The date and time representation should include all relevant information, including the year, month, day, hour, minute, second, and time zone.

  • Ordering

    The date and time values should be ordered from the largest to smallest units, with the year coming first, followed by the month, day, hour, minute, and second.

  • Separators

    Clear and unambiguous separators should be used between the different parts of the date and time representation, such as - between the year, month, and day, and : between the hours, minutes, and seconds.

  • Unambiguous interpretation

    The date and time representation should be unambiguous, regardless of the location or language of the user. This is achieved by using a fixed format for the representation, which is easily recognizable and interpretable by anyone who is familiar with ISO 8601.

  • Internationalization

    The date and time representation should be independent of language and cultural differences, and be easily understood by people from different countries and regions.

3. Best Practice

The best practices ensure that the use of ISO 8601 is consistent, accurate, and easily interpretable by others.

  • Use the full representation

    Whenever possible, use the full representation of the date and time format, including the time zone. This ensures that the representation is complete and unambiguous.

  • Use separators consistently

    Use separators consistently in the date and time representations to make them easier to read and interpret. For example, use - to separate the year, month, and day, and : to separate the hours, minutes, and seconds.

  • Use UTC

    Whenever possible, use Coordinated Universal Time (UTC) in the date and time representations. This helps to avoid confusion and ensures that the representation is consistent across different time zones.

  • Be aware of time zone differences

    When working with dates and times across different time zones, be aware of the differences and adjust the representation accordingly. For example, use the time zone offset to represent the difference between the local time and UTC.

  • Validate inputs

    When parsing or validating date and time inputs, make sure that they conform to the ISO 8601 standard to avoid errors and inconsistencies.

  • Document the use of ISO 8601

    Document the use of ISO 8601 in the code or documentation to ensure that other developers can easily understand and work with the date and time representations.

4. Terminology

Understanding the terms is essential for working with ISO 8601 and ensuring accurate and consistent representations of date and time values.

  • Date

    A date is a specific point in time, represented by a combination of year, month, and day.

  • Time

    Time refers to a specific moment in the day, represented by a combination of hours, minutes, and seconds.

  • Time zone

    A time zone is a region of the world that observes a standardized time, usually based on the Coordinated Universal Time (UTC) offset.

  • UTC

    Coordinated Universal Time (UTC) is the primary time standard by which the world regulates clocks and time. It is the basis for the standardization of time zones around the world.

  • Time interval

    A time interval is a period of time between two points in time, represented by a start and end date and time.

  • Duration

    Duration refers to the length of time between two points in time, represented by a combination of years, months, days, hours, minutes, and seconds.

  • Recurring time interval

    A recurring time interval is a period of time that repeats at regular intervals, such as daily, weekly, or monthly.

  • Time offset

    A time offset is the difference between the local time and Coordinated Universal Time (UTC).

  • Combined date and time

    A combined date and time is a representation of both the date and time in a single value.

  • Leap year

    A leap year is a year that is one day longer than a regular year, with an additional day added to the calendar in February.

References