Why ISO 8601 and not anything else
ISO 8601 is the international standard for representing dates and times as strings. Adopted in 1988, revised most recently in 2019, it is the format used by JSON Schema, OpenAPI, RFC 3339 (a strict subset used by most internet protocols), Date.prototype.toISOString, Python's datetime.isoformat, Postgres' default timestamp output, and basically every modern data tool.
The reason to prefer it over any locale-specific format is simple: strings sort the same as the dates they represent. "2026-01-15" sorts before "2026-02-03" with a plain string comparison. No parsing, no Date object, no surprises. That single property eliminates entire categories of bugs in log analysis, time-series storage, and database indexes.
The two competitors you still see in the wild — MM/DD/YYYY (US English) and DD/MM/YYYY (most of Europe) — are ambiguous between cultures and unsortable as strings. There is no upside.
The format, segment by segment
The full extended form for a date-time is:
2026-05-26T14:32:18.123+02:00
└────────┘ └──────────┘ └─────┘
date time offsetEach part has fixed width and is left-padded with zeros. Year is four digits, month and day are two, hour and minute and second are two each, fractional seconds are three (milliseconds) or six (microseconds), offset is ±HH:MM or the letter Z for UTC.
The T between date and time is required by the standard but some lenient parsers also accept a space. Stick with T: it is unambiguous and what every conformant parser produces.
Time zones and offsets
ISO 8601 represents time-zone information as a numeric offset from UTC, not as a named zone. +02:00 says "two hours ahead of UTC at this exact instant." It does not say which zone — Paris in summer and Athens in winter both have +02:00.
The shorthand Z is identical to +00:00 and is the standard way to represent UTC. Always include an offset if the timestamp represents a specific instant. A timestamp without an offset is ambiguous: "2026-05-26T14:32:18" means 14:32 local time, but in whose locale?
// instant in time — unambiguous
"2026-05-26T14:32:18+02:00"
"2026-05-26T12:32:18Z" // same moment, expressed in UTC
// local time, no instant — fine for calendars, dangerous for logs
"2026-05-26T14:32:18"
// date only — no time, no zone
"2026-05-26"If you store a date that represents a future appointment in a specific city, you want the local datetime plus the IANA zone name (Europe/Paris) as a separate field — the offset will change when DST kicks in. ISO 8601 does not have a slot for the zone name; combine it with a separate column.
The subsets you will see in the wild
ISO 8601 is enormous — it includes week numbers, ordinal days, durations (P1Y2M3D), repeating intervals. Most of it you never need. The subsets that matter:
RFC 3339 is the strict profile used by most internet protocols. It requires the T separator, requires an offset (no naive datetimes), and forbids week-numbering. If you have a free choice, emit RFC 3339 — anything that consumes it consumes ISO 8601 too.
JSON Schema "date-time" format follows RFC 3339. OpenAPI "date" is just the date part. JavaScript's Date.toISOString() always emits UTC with millisecond precision: "2026-05-26T12:32:18.123Z".
In code — parsing and emitting
// JavaScript
new Date('2026-05-26T14:32:18Z').toISOString();
// → "2026-05-26T14:32:18.000Z"
// Python (3.11+)
from datetime import datetime
datetime.fromisoformat('2026-05-26T14:32:18+02:00')
datetime.now(timezone.utc).isoformat()
# → "2026-05-26T12:32:18.123456+00:00"
// Go
import "time"
t, _ := time.Parse(time.RFC3339, "2026-05-26T14:32:18Z")
t.Format(time.RFC3339) // → "2026-05-26T14:32:18Z"
// Rust (with chrono)
use chrono::DateTime;
let dt: DateTime<chrono::Utc> = "2026-05-26T14:32:18Z".parse().unwrap();
dt.to_rfc3339() // → "2026-05-26T14:32:18+00:00"Two things to remember in JavaScript specifically. First, new Date(str) is lenient and accepts garbage ("2026/05/26" becomes a valid date in many engines) — always validate input separately. Second, toISOString() always emits UTC with three-digit milliseconds and Z — no offset variant.
Pitfalls
Excel breaks ISO dates. Open a CSV with ISO date strings in Excel and it will auto-convert them to its locale format. The bytes you saved are not what get displayed. Avoid this by quoting the date column in the CSV or by exporting .xlsx directly — the JSON to Excel tool preserves type.
Two-digit years. "26-05-26" is not ISO 8601 even if it looks like it. The year must be four digits. Parsers that accept two-digit years are guessing; do not rely on the guess.
Leap seconds. ISO 8601 allows 23:59:60 for leap seconds. Most JavaScript engines clamp this to 23:59:59 silently. If you care about leap seconds you are doing astronomy or telemetry, in which case this post is below your level.
Timezone offset confusion. A common bug: storing the offset of the user's browser at the time of recording, then later assuming it is the offset at the timestamp itself. If DST shifted in between, the offset is wrong. Always store either UTC or the local datetime plus the IANA zone name.
Storing dates in JSON
JSON has no native date type. Every date in a JSON document is either a string (the ISO 8601 form) or a number (a Unix timestamp). Strings are more readable and sortable; numbers are smaller and unambiguous about zone.
The convention that wins in 2026: ISO 8601 strings with Z for UTC. Every API, every database, every log aggregator handles them. Numbers (Unix epoch in seconds or milliseconds) are still common in JWTs (exp and iat are seconds) and in time-series databases for storage efficiency. Whichever you pick, document it once at the schema level and stay consistent.
{
"id": "evt_1234",
"type": "user.login",
"created_at": "2026-05-26T14:32:18.123Z",
"valid_until": "2026-05-27T14:32:18Z"
}Validate the format with a JSON Schema check — "format": "date-time" with Ajv plus ajv-formats rejects anything not RFC 3339 compliant. See the JSON Schema validator for the runtime check, and the schema tutorial for the syntax.