Spec meets cheatsheet · Wikipedia overview

ISO 8601

ISO 8601 is the usual way to write dates and times as plain text for interchange: fixed-width numbers, largest unit left (year → … → second), optional separators, and explicit UTC or offsets so sorting and parsing stay predictable across locales.

This page is a practical subset. For edge cases (expanded years, uncertainty, full normative text), use the official standard or specialized profiles such as RFC 3339 where they apply.

Core rules

  • Order: fields run most-significant-first so string sort ≈ chronological order (exceptions: negative years and signed offsets need care).
  • Width: use agreed digit counts and leading zeros (05 not 5).
  • Extended vs basic: hyphens in dates, colons in times → human-readable extended; compact concatenation → basic. Prefer extended in prose and logs; never mix extended date + basic time (or vice versa) in one value.
  • T separates date and time in a combined value (2026-05-16T13:47).
  • Zone: suffix Z means UTC; otherwise append ±hh:mm (or compact ±hhmm / ±hh). No zone ⇒ treated as local — fine in one context, ambiguous across zones or DST.
  • Reduced precision: drop fields from the right only (e.g. 2026-05 = May 2026, not “day 5”).

Forms → examples

One-line mental map; swap patterns for your precision (omit seconds, omit day, etc.).

MeaningShapeExample
Calendar dayYYYY-MM-DD2026-05-16
Calendar day (basic)YYYYMMDD20260516
Month precisionYYYY-MM2026-05
Year onlyYYYY2026
ISO week dayYYYY-Www-D2026-W20-6
Ordinal dayYYYY-DDD2026-136
Time (extended)hh:mm:ss13:47:30
UTC…Z13:47:30Z
Offset±hh:mm+02:00
Instantdate T time zone2026-05-16T13:47:30Z
DurationP…P3DT4H30M
Intervalstart/end2026-05-16T09:00Z/2026-05-17T17:00Z

Calendar dates

Gregorian calendar; YYYY four digits, MM 01–12, DD 01–31.

1981-04-05  ≡  19810405
2026-05      ≡  May 2026 (month precision)
2026         ≡  the calendar year 2026

Week dates

YYYY-Www-D: week W01W53, weekday D = 1 Monday … 7 Sunday. Week 1 is the week whose Thursday falls in the new year (equivalently: containing 4 January).

Monday 29 December 2008  →  2009-W01-1
ISO week-year can differ from Gregorian year near Jan 1 / Dec 29–31

Ordinal dates

Day-of-year DDD is 001–366 ( YYYY-DDD or YYYYDDD ).

1981-04-05  ≡  1981-095

Times & zones

24-hour clock; extended uses : between units. Fractions attach to the smallest present unit with . or , (agree which with partners).

T13:47:30           wall time (local unless paired with offset/Z)
T13:47:30Z          same instant, UTC
T13:47:30+02:00     UTC+2 civil time
T13:47              reduced precision (no seconds)

Combined date & time

Concatenate a complete date (calendar, week, or ordinal), then T, then time. Zone designator follows the whole datetime.

2026-05-16T13:47:30Z
2026-W20-6T09:15:00-05:00
2026-136T23:59:59+00:00

Durations & intervals

Duration (P …): calendar buckets before T (years Y, months M, weeks W, days D), clock counts after T (hours H, minutes M, seconds S). Ambiguity: P1MPT1M (month vs minute).

P3DT4H30M5S     →  3 days + 4h30m5s
PT45S           →  45 seconds only
P6W             →  six weeks

Interval: two bounds separated by /, or start + duration, or duration + end. Recurrence prefix R / Rn/ repeats the pattern.

2007-03-01T13:00:00Z/2008-05-11T15:30:00Z     start/end
2007-03-01T13:00:00Z/P1Y2M10DT2H30M            start + duration
R5/2008-03-01T13:00:00Z/P1D                   repeat: start + 1-day duration, 5×

Trailing fields omitted on the end side inherit from the start (same date, same zone) — handy for same-day ranges.

In practice

Prefer

  • UTC (Z) for server logs and APIs.
  • Explicit offsets for civil-time displays that must round-trip.
  • Extended format when humans read it; basic when bandwidth or storage is tight.
  • Full precision in protocols; truncate only by agreement.

Avoid / clarify

  • Timezone-less combined datetimes in cross-border data.
  • Assuming YYYY-MM-DD without calendar agreement (not every locale uses Gregorian display).
  • Treating P1M duration as a fixed number of days.

← ptvz interchange profile · Explorer