ISO 8601

ISO 8601 is the international standard for writing dates and times as text. The current time in UTC reads:

UTC offset. The difference from UTC, written ±hh:mm. This is your offset right now. It changes with daylight saving time, which is why an offset is not a time zone.

1

Representations

Every representation has an extended form with separators and a basic form without them. Use extended unless something requires otherwise. The values below show the current time.

RepresentationPatternExtendedBasic
Calendar dateYYYY-MM-DD2026-11-1420261114
Ordinal dateYYYY-DDD2026-3182026318
Week dateYYYY-Www-D2026-W46-62026W466
Local timehh:mm:ss07:22:49072249
UTC timehh:mm:ssZ07:22:49Z072249Z
Time and offsethh:mm:ss±hh:mm07:22:49+00:00072249+0000
Date and timeYYYY-MM-DDThh:mm:ssZ2026-11-14T07:22:49Z20261114T072249Z
Date, time, offsetYYYY-MM-DDThh:mm:ss±hh:mm2026-11-14T07:22:49+00:0020261114T072249+0000
Intervalstart/duration2026-11-14/P1M20261114/P1M
2

Builder

Date
Time
Zone
Form

2026-11-14T07:22:49Z

YYYY-MM-DDThh:mm:ssZ

Valid ISO 8601 and RFC 3339. Suitable for APIs, logs and storage.

3

Durations and intervals

A duration begins with P. Date units come first. T separates them from the time units, so P1M is a month and PT1M is a minute. Type any field below to build one.

PT

P1Y2M10DT30M is 1 year, 2 months, 10 days and 30 minutes.

ExpressionMeaning
P3Y6M4DT12H30M5S3 years, 6 months, 4 days, 12 hours, 30 minutes, 5 seconds
PT0.5SHalf a second. Only the smallest unit may carry a fraction.
P2WTwo weeks
2026-11-14/2026-12-31Interval: from today to the end of the year
2026-11-14/P1MInterval: one month, starting today
P6M/2026-11-14Interval: the six months ending today
2026-11-14T09:00:00Z/2026-11-14T17:00:00ZInterval: 09:00 to 17:00 UTC today
R5/2026-11-14/P1MRepeats five times, monthly, from today
R/PT1HRepeats hourly, without end
4

Common mistakes

  1. The week-year can differ from the calendar year. Week 01 is the week that contains the year's first Thursday, so a few days at each end of a year can belong to the neighbouring week-year.

    2024-12-30 = 2025-W01-1
    2021-01-01 = 2020-W53-5

  2. A time without an offset is local time. The string doesn't say which locality, and some local times never happen. Store instants in UTC or with their offset.

    2026-03-08T02:30:00
    doesn't exist in most of the US

  3. M means months before T and minutes after it. Leaving out the T changes a minute into a month.

    P1M = 1 month
    PT1M = 1 minute

  4. Strings only sort chronologically when they match. They need the same representation, the same precision and the same offset. Normalize to UTC before sorting or comparing as text.

    10:00+02:00 sorts after 09:00Z
    but happens an hour earlier

  5. RFC 3339 is a stricter profile. It requires a full date, a full time and an offset, in extended form. Week dates, ordinal dates and durations are ISO 8601 only.

    2026-W46-2 ISO 8601 only
    2026-11-10T18:05:00Z both

  6. An offset is not a time zone. An offset records one moment's distance from UTC. A zone such as America/Chicago is a set of rules that changes with daylight saving time. For future local events, store the zone name.

    America/Chicago
    −06:00 in winter, −05:00 in summer

5

In code

The usual way to produce a UTC timestamp in each language. The output column shows the current time.

LanguageExpressionOutput
JavaScriptnew Date().toISOString()2026-11-14T07:22:49.326Z
TemporalTemporal.Now.instant().round("second").toString()2026-11-14T07:22:49Z
Pythondatetime.now(timezone.utc).isoformat(timespec="seconds")2026-11-14T07:22:49+00:00
PHP(new DateTimeImmutable('now', new DateTimeZone('UTC')))->format(DATE_ATOM)2026-11-14T07:22:49+00:00
Laravelnow()->toIso8601ZuluString()2026-11-14T07:22:49Z
Gotime.Now().UTC().Format(time.RFC3339)2026-11-14T07:22:49Z
RustUtc::now().to_rfc3339_opts(SecondsFormat::Secs, true)2026-11-14T07:22:49Z
RubyTime.now.utc.iso86012026-11-14T07:22:49Z
JavaInstant.now().truncatedTo(ChronoUnit.SECONDS).toString()2026-11-14T07:22:49Z
C#DateTime.UtcNow.ToString("o")2026-11-14T07:22:49.3260000Z
PostgreSQLto_char(now() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')2026-11-14T07:22:49Z
6

History

  1. 1988First edition. Replaced ISO 2014, 2015, 2711, 3307 and 4031, which had covered dates, week numbers, ordinal days, times and offsets separately.
  2. 2000Second edition.
  3. 2002RFC 3339 defines a profile of ISO 8601 for internet protocols.
  4. 2004Third edition.
  5. 2019Split into two parts. Part 1 holds the basic rules. Part 2 holds extensions, including the Library of Congress's Extended Date/Time Format.
⌂