tools / regex library / iso 8601 date
regex pattern · ready to copy

Regex for matching ISO 8601 dates

Match `YYYY-MM-DD` and `YYYY-MM-DDTHH:MM:SS(.fff)?(Z|±HH:MM)?`.

intermediate javascript / pcre / python4 use cases

The pattern

\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:[T ](?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)?)?\b

Test cases

InputResult
2026-04-28matches
2026-04-28T14:30:00Zmatches
2026-04-28 14:30:00.123+02:00matches
2026-13-01 (month 13)rejects
26-04-28 (2-digit year)rejects
April 28 2026rejects

Edge cases & caveats

Doesn't enforce real-world day count per month (Feb 31 matches). Use a date library after regex match for validity. Excludes ISO week-date format (`2026-W17-2`).

Common use cases

Try variations against your data
regexlab is a free in-browser tester with side-by-side match highlighting, group inspector, and named-capture export to JS/Python/PCRE.
Open regexlab  

Related

ipv6 address · us zip code · jwt · url