Back to Blog
DateTimeISO 8601Standards

ISO 8601: The Definitive Guide to Date and Time Formats

March 10, 2026 · 7 min read

Is 03/04/2024 the 3rd of April or the 4th of March? It depends entirely on whether you're in the US or Europe — and this ambiguity has caused real-world disasters in aviation, finance, and healthcare. ISO 8601 exists to eliminate this problem entirely.

What Is ISO 8601?

ISO 8601 is an international standard for representing dates and times, published by the International Organization for Standardization. Its core principle is simple: represent dates from largest to smallest unit — year, month, day, hour, minute, second — so that dates sort correctly alphabetically and are unambiguous in any culture.

The canonical full datetime format is: 2024-03-31T14:30:00Z

Date Formats

FormatExampleDescription
YYYY-MM-DD2024-03-31Calendar date (most common)
YYYY-MM2024-03Year and month only
YYYY2024Year only
YYYY-Www2024-W13Week date (week 13 of 2024)
YYYY-Www-D2024-W13-7Week date with day (1=Mon, 7=Sun)
YYYY-DDD2024-091Ordinal date (day 91 of the year)

Time Formats

FormatExampleDescription
hh:mm:ss14:30:00Hours, minutes, seconds
hh:mm14:30Hours and minutes
hh:mm:ss.sss14:30:00.000With milliseconds

Combined Datetime

Date and time are separated by the letter T:

2024-03-31T14:30:00
2024-03-31T14:30:00.000
2024-03-31T14:30:00Z        ← UTC
2024-03-31T14:30:00+05:30   ← IST (UTC+5:30)
2024-03-31T14:30:00-08:00   ← PST (UTC-8)

Timezone Designators

This is where most bugs happen. ISO 8601 supports three forms:

DesignatorExampleMeaning
Z2024-03-31T14:30:00ZUTC (Zulu time) — always safe to store
+HH:MM2024-03-31T14:30:00+05:30UTC offset (positive)
-HH:MM2024-03-31T14:30:00-08:00UTC offset (negative)

A datetime without a timezone designator is ambiguous — it could mean local time (which varies by machine) or UTC. This is a common source of off-by-hours bugs. Always include a timezone when storing or transmitting datetimes.

Duration Format

ISO 8601 also defines a duration format: P (period) followed by date components, T for the time section:

P1Y2M3DT4H5M6S   ← 1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds
PT30M             ← 30 minutes
P1D               ← 1 day
PT1H30M           ← 1 hour 30 minutes

Sorting Advantage

One of the most practical benefits of ISO 8601 is that dates in this format sort correctly as plain strings — no custom comparators needed:

// These sort correctly alphabetically AND chronologically
"2024-01-15"
"2024-03-31"
"2024-12-01"
"2025-01-01"

Compare this to US format (03/31/2024) or European format (31/03/2024), which sort incorrectly as strings.

Using ISO 8601 in Code

JavaScript

// Parse ISO 8601
new Date("2024-03-31T14:30:00Z")

// Output ISO 8601 (always UTC)
new Date().toISOString()  // "2024-03-31T14:30:00.000Z"

// Current datetime in local timezone (ISO-like, no Z suffix)
new Date().toLocaleString("sv-SE")  // "2024-03-31 14:30:00"

Python

from datetime import datetime, timezone

# Current UTC time as ISO 8601
datetime.now(timezone.utc).isoformat()
# "2024-03-31T14:30:00.000000+00:00"

# Parse ISO 8601 (Python 3.11+)
datetime.fromisoformat("2024-03-31T14:30:00+05:30")

Try It

Use the DateTime Tools on io9.me to detect date formats, convert between them, and decode timestamps — all in your browser.