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.
- ISO 8601-1:2019 (iso.org)
- RFC 3339 (rfc-editor.org)
- RFC 9557 (rfc-editor.org)
Calendar dates
| Example | Form |
|---|---|
2026-11-23 | Extended |
20261123 | Basic |
2026-11 | Month precision |
2026 | Year precision |
Extended dates use -; basic dates omit separators. Reduced precision is allowed for months and years.
See: ISO 8601-1:2019
Week dates
| Example | Form |
|---|---|
2026-W48-1 | Monday of week 48 |
2026W481 | Basic |
2026-W48 | Week 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
| Example | Meaning |
|---|---|
2026-327 | Day 327 of 2026 |
2026-327T10:30Z | With 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
| Example | Meaning |
|---|---|
10:30 | Hour and minute |
10:30:00 | With seconds |
T103000 | Basic form |
24:00:00 | End 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
| Example | Separator |
|---|---|
10:30:00.123 | Dot (RFC 3339) |
10:30:00,123 | Comma (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
| Example | Meaning |
|---|---|
10:30:00Z | UTC |
10:30:00+02:00 | Two hours ahead |
10:30:00-05:00 | Five hours behind |
10:30:00+0000 | Basic 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
| Example | Meaning |
|---|---|
2026-11-23T10:30:00Z | UTC |
2026-11-23T10:30:00+02:00 | With offset |
2026-11-23T10:30:00.123Z | Fractional 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
| Example | Meaning |
|---|---|
P1Y2M3D | Years, months, days |
PT1H30M | Hours and minutes |
P2W | Two weeks |
PT0.5S | Half 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
| Token | Meaning |
|---|---|
Y | years |
M | months before T |
D | days |
H | hours after T |
M | minutes after T |
S | seconds 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
| Example | Meaning |
|---|---|
2026-11-23T10:30Z/2026-11-23T12:00Z | Start and end |
2026-11-23T10:30Z/PT90M | Start and duration |
PT90M/2026-11-23T12:00Z | Duration and end |
2026-11-23/11-24 | Date 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
| Example | Meaning |
|---|---|
R3/2026-11-23T10:00Z/PT1H | Three occurrences |
R/2026-11-23T10:00Z/PT1H | Indefinite |
R0/2026-11-23T10:00Z/PT1H | None |
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').
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!