DevKits

Dates & Times

Match an ISO 8601 date-time

Validate ISO 8601 timestamps like 2025-06-15T14:30:00Z.

Pattern

Regular expression

\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)?

How it works

Full ISO 8601 timestamp: date, `T`, time (HH:MM:SS with optional fractional seconds), and optional `Z` (UTC) or `±HH:MM` timezone offset.

Matches

  • 2025-06-15T14:30:00Z
  • 2025-06-15T14:30:00.123+02:00
  • 2025-06-15T14:30:00

Non-matches

  • 2025-06-15 14:30:00 (space instead of T)
  • 2025-06-15T25:00:00Z (bad hour)

Common gotchas

For real parsing, use `Date.parse` / `datetime.fromisoformat` — regex accepts a superset of valid timestamps and does not validate calendar semantics.

Language snippets

JavaScript

const iso = /\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)?/g;

Python

from datetime import datetime
datetime.fromisoformat("2025-06-15T14:30:00+02:00")

Go

t, err := time.Parse(time.RFC3339, "2025-06-15T14:30:00Z")

Java

Instant.parse("2025-06-15T14:30:00Z")

Related patterns

Try any pattern live in the Regex Tester