Date and Time
Temporal values — dates, times, and date-times as annotated strings.
Temporal values are written as annotated strings in ISO 8601-compatible formats, with a prefix that selects the kind: d for a date, t for a time, and dt for a combined date-time. A parser converts them to native date/time objects on deserialization.
The content between the quotes must be valid for its kind.
Syntax
temporalValue = dateValue | timeValue | dateTimeValue
dateValue = "d" ("'" dateContent "'" | '"' dateContent '"')
timeValue = "t" ("'" timeContent "'" | '"' timeContent '"')
dateTimeValue = "dt" ("'" dateTimeContent "'" | '"' dateTimeContent '"')
dateContent = yearPart [monthPart [dayPart]]
timeContent = hourPart [minutePart [secondPart [millisecondPart]]]
dateTimeContent = dateContent ["T" timeContent] [timeZone]
yearPart = digit digit digit digit
monthPart = ["-"] ( "0" digit | "1" ("0" | "1" | "2") )
dayPart = ["-"] ( "0" digit | ("1" | "2") digit | "3" ("0" | "1") )
hourPart = [":"] ( ("0" | "1") digit | "2" ("0" | "1" | "2" | "3") )
minutePart = [":"] ("0" | "1" | "2" | "3" | "4" | "5") digit
secondPart = [":"] ("0" | "1" | "2" | "3" | "4" | "5") digit
millisecondPart = "." digit digit digit
timeZone = "Z" | ("+" | "-") hourPart [minutePart]Structural characters
d
Date prefix
U+0064
Date-only value
t
Time prefix
U+0074
Time-only value
dt
DateTime prefix
—
Combined date-time value
' "
Quotes
U+0027 U+0022
Enclose the temporal content
-
Hyphen
U+002D
Date separator (optional); also a negative offset
:
Colon
U+003A
Time separator (optional)
.
Period
U+002E
Millisecond separator
T
Letter T
U+0054
Separates the date and time
Z
Letter Z
U+005A
UTC designator
+
Plus
U+002B
Positive timezone offset
Valid forms
Dates — d'…'
Times — t'…'
Date-times — dt'…'
A combined example
Format specifications
Date
YYYY-MM-DD
YYYYMMDD
YYYY-MM, YYYY
missing month/day → 01
Time
HH:mm:ss.SSS
HHmmss.SSS
HH:mm:ss, HH:mm, HH
missing parts → 00
DateTime
date T time [zone]
—
any date form + optional time
missing time → 00:00:00.000; missing zone → UTC
Hours use the 24-hour clock (00–23). A date-only value is treated as UTC midnight; a time-only value uses a reference date and is treated as UTC.
Invalid forms
Out-of-range or malformed temporals produce the stable error code invalid-datetime:
Timezone handling
Explicit UTC —
dt'2024-03-20T14:30:45Z'is UTC.Explicit offset —
dt'2024-03-20T14:30:45+05:30'carries that offset; its UTC equivalent is2024-03-20T09:00:45Z.No timezone — a date-time with no zone is treated as UTC.
Valid offset range — offsets run from
-12:00to+14:00; both±HH:mmand±HHMMare accepted on input.On serialization, an implementation SHOULD emit offsets in the
±HH:mmform and round-trip explicit timezone information unchanged.
Implementation status (beta)
The reference implementation has known gaps in temporal parsing; a conformant parser SHOULD behave as specified above, not as the current implementation does:
Overflow dates are normalized rather than rejected:
d'2024-02-30'becomes2024-03-01instead of raisinginvalid-datetime.Over-long fractions are truncated: a millisecond field with more than three digits is truncated to three rather than rejected.
See Also
Value Representations — all value types
Numeric Values — the numeric forms
Date and Time — date/time schemas
Last updated
Was this helpful?
