ISO 8601 Date Format Explained

ISO 8601 writes dates as year, month, day with four, two and two digits: 2026-12-06. It is unambiguous, it sorts correctly as text, and every programming language can parse it. If you choose one date format for a project, choose this one.

The basic form

YYYY-MM-DD. 6 December 2026 is 2026-12-06. Single-digit months and days are padded with a zero, which is what makes text sorting work.

Compare with 12/06/2026, which is 6 December in the United States and 12 June almost everywhere else. ISO order removes that ambiguity entirely.

Work with two dates in any format.

Open the Date Difference Calculator →

Adding time

Append T and the time: 2026-12-06T14:30:00. The T is a separator, not a variable. Seconds can be omitted, and fractional seconds follow a decimal point: 2026-12-06T14:30:00.250.

For a time with a zone, add Z for UTC or an offset: 2026-12-06T14:30:00Z or 2026-12-06T16:30:00+02:00. Both describe the same instant.

Why it sorts correctly

Because the largest unit comes first, alphabetical order equals chronological order. A directory listing of files named with ISO dates is automatically in date order, and a database string sort matches a date sort.

No other common format has this property. With DD/MM/YYYY, a sort puts all the first-of-month dates together, which is useless.

Where it is required

The common mistakes

Duration and intervals

ISO 8601 also defines durations: P1Y2M3D means one year, two months, three days, and PT1H30M means one hour thirty minutes. An interval can be written as start/end or start/duration.

These appear in calendar standards and APIs. They are worth recognising even if you rarely write them.

Choosing a format for a project

Store and transmit ISO 8601 in UTC. Display in the user's local format, which for a US audience might be December 6, 2026 and for a UK audience 6 December 2026.

Keeping storage and display separate avoids both ambiguity and the complaint that dates look foreign.

What it does not solve

The format removes ambiguity, not time zone confusion. A string without an offset is still a local time, and local times are ambiguous during daylight-saving transitions, when 01:30 can occur twice.

For anything stored or compared, include the offset or use Z.

A practical rule

When you see a date in a log, a filename or an API, check the order of the first two numbers. If the first is four digits, it is ISO and you can trust it. If not, you need to know the source's convention before comparing anything.

Week dates and ordinal dates

ISO 8601 also defines week dates such as 2026-W49-7, where the week number follows ISO rules and weeks start on Monday. These appear in manufacturing, payroll and some European business contexts.

Ordinal dates, 2026-340, give the day of the year. They are rare outside specialised systems but worth recognising when a date looks like a year followed by three digits.

Sorting mixed formats

If a spreadsheet holds a mix of ISO and local-format dates as text, sorting will not produce chronological order. Convert everything to real date values first, then format for display, rather than sorting text and hoping.

Formatting rules in different languages

JavaScript has toISOString for UTC output. Python has datetime.isoformat, which keeps the offset if the datetime is timezone-aware. SQL has to_char with a format string, and most databases will cast a timestamp to text in ISO form directly.

In each case the rule is the same: store the instant, format at the edge, and never let a string without an offset be treated as UTC.

Frequently asked questions

Is ISO 8601 the same as RFC 3339?

RFC 3339 is a stricter profile of ISO 8601 for internet timestamps. Most ISO timestamps are valid RFC 3339.

Should I include the time zone?

Yes, for anything stored or transmitted. A time without an offset is ambiguous.

Can I use ISO dates in filenames?

Yes. They sort correctly, which is the main reason to use them there.

Sources

More free tools

Related guides