ISO 8601 is an international standard for representing date and time information. It specifies a format for date and time strings that is widely used in computer systems and on the internet.
The basic format of an ISO 8601 date string is YYYY-MM-DD, where YYYY is the four-digit year, MM is the two-digit month, and DD is the two-digit day. For example, the date March 14, 2022 would be represented as 2022-03-14 in ISO 8601 format.
ISO 8601 also allows for the representation of time information in the format THH:MM:SS, where T is the separator between the date and time components and HH, MM, and SS represent the hours, minutes, and seconds, respectively. For example, the time 1:23:45 PM would be represented as 13:23:45 in ISO 8601 format.
Combined date and time information can be represented in ISO 8601 format as YYYY-MM-DDTHH:MM:SS, with the T separating the date and time components. For example, the datetime March 14, 2022 at 1:23:45 PM would be represented as 2022-03-14T13:23:45 in ISO 8601 format.
Here are some examples of ISO 8601 date/time formats:
- Date only:
2022-03-14 - Time only:
13:23:45 - Date and time:
2022-03-14T13:23:45 - Date and time with timezone offset:
2022-03-14T13:23:45-04:00 - Date only with week number:
2022-W11 - Date with week number and weekday:
2022-W11-1(Monday) - Duration:
PT1H30M(1 hour and 30 minutes) - Period:
2022-03-14/P1M(period of 1 month starting from March 14, 2022)
Note that the T separator is used between the date and time components in ISO 8601 format, and timezone offsets are represented as a positive or negative offset from Coordinated Universal Time (UTC). The W character is used to represent weeks, with the week number following the W character and the weekday number following the date component with a - separator. Duration and period strings begin with P, followed by the duration or period value and units (H for hours, M for minutes, D for days, W for weeks, M for months, and Y for years).