ISO 8601 · dates · times · durations · intervals

The complete ISO 8601 reference

Calendar, week, ordinal dates. Times with and without millis. Offsets, durations and intervals. Each row shows the format and a concrete example.

ISO 8601 Cheatsheet
Sections
8
topics
Rows
22
patterns
Coverage
ISO 8601
spec
Mode
reference
static
SpecISO 8601:2019 (extended + basic)
input · how to read
Layout
Format column is the spec syntax. Example column shows what real data looks like. Note adds context.
Tip
For APIs, default to YYYY-MM-DDTHH:MM:SSZ. RFC 3339 is a stricter subset of ISO 8601 — also accepted.
output · sections

Calendar dates

YYYY-MM-DD
2024-01-15
Extended date (most common).
YYYYMMDD
20240115
Basic date (no separators).
--MM-DD
--01-15
Month-day only (year unknown).
YYYY-MM
2024-01
Year-month only.
YYYY
2024
Just the year.

Week dates

YYYY-Www-D
2024-W03-1
Year, ISO week, day-of-week (1=Mon).
YYYY-Www
2024-W03
Year + ISO week.

Ordinal dates

YYYY-DDD
2024-015
Day of year.

Times

hh:mm:ss
14:30:00
Extended time.
hhmmss
143000
Basic time.
hh:mm:ss.sss
14:30:00.250
With milliseconds.
hh:mm
14:30
No seconds.

Time zones

Z
14:30:00Z
UTC (Zulu time).
±hh:mm
14:30:00+05:00
Offset from UTC.
±hhmm
143000+0500
Basic offset.

Date + time

YYYY-MM-DDTHH:MM:SS
2024-01-15T14:30:00
T separator. No timezone = local.
YYYY-MM-DDTHH:MM:SSZ
2024-01-15T14:30:00Z
UTC instant (most common in APIs).
YYYY-MM-DDTHH:MM:SS±hh:mm
2024-01-15T14:30:00+05:00
With explicit offset.

Durations

PnYnMnDTnHnMnS
P3Y6M4DT12H30M5S
ISO 8601 duration: 3y 6mo 4d 12h 30m 5s.
PnW
P2W
Weeks-only duration.

Intervals

<start>/<end>
2024-01-01/2024-12-31
Range of two dates.
<start>/<duration>
2024-01-01/P1M
Start + duration.
Quick Start

How to use ISO 8601

When in doubt, use YYYY-MM-DDTHH:MM:SSZ. It's unambiguous, sorts lexicographically and is accepted by every modern API and database.

  1. 01

    Pick scope

    Date only? Date + time? With offset? Duration? Pick the matching section.

    Parsing accepts ISO 8601, RFC 3339, RFC 2822, and Unix epoch seconds/milliseconds. The Date constructor handles the rest with browser-engine consistency.

    scopeISO 8601RFC 3339epochlive
    scope · timestampfind · ISO
    date + time
    loaded · ISO 8601zone · ready
  2. 02

    Add offset

    Z for UTC, ±HH:mm for local. Avoid offset-less forms in storage.

    All math runs in UTC internally to avoid DST landmines; presentation converts back to the user’s zone via Intl.DateTimeFormat.

    offsetUTC mathIntlDST-safelive
    tz · optionsZ · live
    ...Z
    options applied · UTCDST-safe
  3. 03

    Use durations

    PnYnMnDTnHnMnS — P prefix, then years/months/days, T splits date+time.

    Output respects the chosen timezone offset (Z vs +05:30) and pads digits per ISO conventions so sorts stay chronological.

    duroffsetzone-awaresortablepadded
    P · computedT · ready
    P1Y6M
    computed · instantsortable
  4. 04

    Intervals

    start / end OR start / duration with a slash separator.

    Copy writes via the Async Clipboard API; nothing pings a time server — the browser’s clock is the only oracle.

    rangeclipboardno oracledeterministicclient-side
    ✓ · copiedready · done
    2024-01-01/P1M
    shipped · ready to shipsuccess
Pro tips

Time math without DST landmines

Always store UTC

Convert to local for display only. UTC storage avoids DST jumps and timezone drift in databases.

Watch leap seconds

POSIX time doesn’t count leap seconds; some systems do. Don’t use timestamps for sub-second precision across boundaries.

Prefer Temporal eventually

The Date API has many quirks. Temporal is shipping in modern engines and handles zones correctly.

Cron is timezone-tricky

Cron expressions run in the daemon’s local zone unless told otherwise. Pin a TZ explicitly for predictable runs.

ISO 8601 sorts naturally

YYYY-MM-DDTHH:mm:ss sorts correctly as a string. Don’t use US-style MM/DD/YYYY for anything machine-readable.

Beware Y2K38

Signed 32-bit Unix timestamps overflow in 2038. Use 64-bit storage end-to-end for long-lived systems.

Use Cases

When to reach for ISO 8601

APIs, logs, storage.

REST APIs

The default datetime format everywhere. Math runs in UTC under the hood to dodge DST jumps — local time is only for display. That means scheduling logic and date diffs survive March / November fall-back without the classic off-by-one-hour bug.

DST-safe

Logs

Sortable lexicographically — perfect for log aggregators. Browser clock is the only source — no external time server, no privacy leak, no rate limit. Pair with NTP-synced server time for high-accuracy use cases, but for human-scale work the browser clock is plenty.

UTC-correct

Database storage

Round-trips through every modern engine. ISO 8601 output sorts naturally as strings, perfect for filenames (report-2026-01-15.pdf) and log lines that need chronological ordering without parsing. Drop into S3 keys for free time-bucketing.

ISO-sortable

Filenames

report-2024-01-15.csv sorts itself. Pairs cleanly with cron, scheduled tasks, and timestamped log analysis. The tool's output drops directly into APScheduler, Linux cron, or GitHub Actions schedule expressions without re-formatting.

spec-grade

Durations

PT1H30M is unambiguous across locales. Output respects the chosen timezone offset (Z vs +05:30) so REST APIs and database TIMESTAMP WITH TIME ZONE columns round-trip cleanly. No ambiguity between &quot;noon UTC&quot; and &quot;noon local&quot;.

zone-aware

i18n safe

No US vs EU ambiguity — single canonical form. Confirms the difference between epoch seconds (10 digits) and milliseconds (13 digits) before you commit code that mis-multiplies by 1000 — a classic bug in cross-language time handling.

i18n
FAQ

Frequently asked questions

RFC 3339 is a stricter profile of ISO 8601. Most APIs accept either.
Z is unambiguous and clock-independent. Offsets preserve speaker context.
In Europe and manufacturing. Less common in Anglo software.
ISO 8601 allows them with a +/- sign on YYYY for BCE dates. Most parsers don't accept them.
No. This page is a static reference.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!