Dates

Introduction

ISO 8601 formats dates, times, durations and intervals as unambiguous text. Extended forms such as 2026-11-23T10:30:00Z also sort as strings.

Calendar dates

ExampleForm
2026-11-23Extended
20261123Basic
2026-11Month precision
2026Year precision

Extended dates use -; basic dates omit separators. Reduced precision is allowed for months and years.

See: ISO 8601-1:2019

Week dates

ExampleForm
2026-W48-1Monday of week 48
2026W481Basic
2026-W48Week without day

Week 01 contains the first Thursday, so the week-year can differ from the calendar year.

See: ISO 8601-1:2019

Ordinal dates

ExampleMeaning
2026-327Day 327 of 2026
2026-327T10:30ZWith a time

Day numbers run from 001 to 365, or 366 in leap years. "Julian date" is a misleading name for this form.

See: ISO 8601-1:2019

Times

Time of day

ExampleMeaning
10:30Hour and minute
10:30:00With seconds
T103000Basic form
24:00:00End of day

24:00:00 is the end of a day in ISO 8601-1:2019/Amd 1:2022; RFC 3339 excludes it.

See: RFC 3339 §5.7

Fractional seconds

ExampleSeparator
10:30:00.123Dot (RFC 3339)
10:30:00,123Comma (ISO 8601)

The fraction applies to the smallest unit present. ISO 8601 allows either mark; RFC 3339 uses the dot.

See: RFC 3339 §5.6

UTC and offsets

ExampleMeaning
10:30:00ZUTC
10:30:00+02:00Two hours ahead
10:30:00-05:00Five hours behind
10:30:00+0000Basic offset

Z means +00:00. An offset is local time minus UTC; lowercase t and z are also accepted.

See: RFC 3339 §4.2, §5.6

Date and time

ExampleMeaning
2026-11-23T10:30:00ZUTC
2026-11-23T10:30:00+02:00With offset
2026-11-23T10:30:00.123ZFractional seconds

T separates the date and time. RFC 3339 requires a full date, full seconds and an explicit offset.

See: RFC 3339 §5.6

Sorting

2026-11-23T08:30:00Z
2026-11-23T10:30:00Z
2026-11-24T00:15:00Z

Fixed-width UTC strings sort chronologically as plain text when offsets are spelled the same and fractional precision matches.

See: RFC 3339 §5.1

Durations and intervals

Duration

ExampleMeaning
P1Y2M3DYears, months, days
PT1H30MHours and minutes
P2WTwo weeks
PT0.5SHalf a second

P starts a duration; T separates date and time parts. P1M is one month, while PT1M is one minute.

See: ISO 8601-1:2019

Duration fields

TokenMeaning
Yyears
Mmonths before T
Ddays
Hhours after T
Mminutes after T
Sseconds after T

Zero values may be omitted, but at least one field is required: PT0S is valid, P is not.

See: ISO 8601-1:2019

Intervals

ExampleMeaning
2026-11-23T10:30Z/2026-11-23T12:00ZStart and end
2026-11-23T10:30Z/PT90MStart and duration
PT90M/2026-11-23T12:00ZDuration and end
2026-11-23/11-24Date range

A slash separates start and end. Omitted end fields are copied from the start, so /11-24 keeps the year.

See: ISO 8601-1:2019

Repeating intervals

ExampleMeaning
R3/2026-11-23T10:00Z/PT1HThree occurrences
R/2026-11-23T10:00Z/PT1HIndefinite
R0/2026-11-23T10:00Z/PT1HNone

R3 means three occurrences, bare R repeats indefinitely, and R0 means none.

See: ISO 8601-1:2019

In code

JavaScript

new Date('2026-11-23T10:30:00+02:00')
  .toISOString()  // '2026-11-23T08:30:00.000Z'

Date parses extended date-times; date-only strings are treated as UTC, and week or ordinal dates are not parsed.

See: Date.parse

Python

from datetime import datetime
dt = datetime.fromisoformat('2026-11-23T10:30:00+00:00')
dt.isoformat()  # '2026-11-23T10:30:00+00:00'

fromisoformat() accepts extended forms and offsets. Weeks use date.fromisocalendar(), ordinals use strptime('%Y-%j').

See: datetime.fromisoformat

Unix date

date -u -d '2026-11-23T10:30:00Z' '+%Y-%m-%dT%H:%M:%SZ'
# 2026-11-23T10:30:00Z

GNU date reads ISO timestamps and reformats them with a + format string.

See: date(1)

0 Comments for this cheatsheet. Write yours!