ISO 8601 date and time formats
ISO 8601 is the international standard for representing dates, times, durations and intervals as unambiguous text. It underpins RFC 3339, most web APIs, and database timestamp formats. This reference groups the standard’s representations — dates, times, durations and intervals — and shows each in both basic and extended form with a worked example.
How it works
A complete ISO 8601 timestamp combines a date and a time joined by T, optionally with a timezone designator: 2026-06-11T14:30:00Z.
Dates come in three flavours: calendar (YYYY-MM-DD), ordinal (YYYY-DDD, day-of-year), and week date (YYYY-Www-D). Week numbering is ISO-specific: weeks start Monday, and week 1 holds the year’s first Thursday.
Times are hh:mm:ss with optional fractional seconds (.sss) and a timezone: Z for UTC or ±hh:mm for an offset. Reduced precision is allowed, e.g. 14:30.
Durations use the P[n]Y[n]M[n]D T[n]H[n]M[n]S grammar — a leading P, then date parts, then T before time parts. PT0S and P0D both denote zero.
Intervals combine two of the above with a /: start/end (2026-06-01/2026-06-30), start/duration (2026-06-01/P1M), or duration/end (P1M/2026-06-30).
Quick-reference table
| Category | Pattern | Example |
|---|---|---|
| Calendar date (extended) | YYYY-MM-DD | 2026-06-11 |
| Calendar date (basic) | YYYYMMDD | 20260611 |
| Ordinal date | YYYY-DDD | 2026-162 |
| ISO week date | YYYY-Www-D | 2026-W24-4 |
| Time (UTC) | hh:mm:ssZ | 14:30:00Z |
| Time with offset | hh:mm:ss±hh:mm | 16:30:00+02:00 |
| Full datetime (UTC) | YYYY-MM-DDThh:mm:ssZ | 2026-06-11T14:30:00Z |
| Duration | PnYnMnDTnHnMnS | P1Y2M10DT2H30M |
| Interval (start/end) | start/end | 2026-06-01/2026-06-30 |
| Interval (start/duration) | start/duration | 2026-06-01/P1M |
Worked example across all representations
The single instant 11 June 2026 at 14:30:00 UTC expressed in every major ISO 8601 form:
calendar date 2026-06-11
ordinal date 2026-162
ISO week date 2026-W24-4 (Thursday of week 24)
full UTC datetime 2026-06-11T14:30:00Z
with +02:00 offset 2026-06-11T16:30:00+02:00
basic datetime 20260611T143000Z
date-only basic 20260611
duration from epoch P2026Y6M11DT14H30M (not how durations are used — see below)
Duration grammar explained
A duration string always starts with P. After that, date parts come first, then a T separator before any time parts:
P 1 Y 2 M 10 D T 2 H 30 M
│ │ │ │ │ │ │ │
│ 1 year 2 months 10 days 2 hours 30 minutes
P for Period
Omit any zero component. P1Y is one year; PT30M is exactly 30 minutes; P0D is the conventional way to express zero duration. The standard does not mandate any particular component to be present as long as the string is unambiguous.
Common pitfalls
Local time without a timezone designator. A string like 2026-06-11T14:30:00 is technically a local datetime — it has no timezone information and its meaning depends entirely on the reader’s context. This causes bugs when records are written in one timezone and read in another. In APIs and storage, always include Z or an explicit offset.
Confusing ISO week-year and calendar year. The ISO week number belongs to the year that contains the week’s Thursday. So 1 January 2027 (a Friday) belongs to 2026-W53, not 2027-W01. Use the week-date form 2026-W53-5 to express it unambiguously; never assume the ISO year matches the calendar year in early January or late December.
Basic vs. extended interoperability. Extended format (separators: 2026-06-11) is far more widely understood by libraries and humans. Basic format (no separators: 20260611) is allowed by ISO 8601 but can confuse parsers that expect separators. Prefer extended unless compactness or a specific system requires basic.
Why ISO 8601 matters
ISO 8601 strings sort chronologically when sorted as plain strings — 2026-06-11 comes before 2026-12-01 lexicographically, which is exactly the chronological order. This property makes them ideal for filenames, log keys, and database primary keys where sorting by name also means sorting by time. Ambiguous formats like 11/06/2026 lose this property and introduce locale-dependent misreadings (is that June 11 or November 6?).