Skip to main content
CalcHive

Regex for ISO 8601 DateTime

Matches ISO 8601 datetime strings with timezone. Example: 2026-03-15T14:30:00Z or 2026-03-15T14:30:00+05:30.

Pattern

/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/

Pattern Breakdown

TokenExplanation
\d{4}-\d{2}-\d{2}Date in YYYY-MM-DD format
TLiteral T separator between date and time
\d{2}:\d{2}:\d{2}Time in HH:MM:SS format
(?:\.\d+)?Optional fractional seconds
(?:Z|[+-]\d{2}:\d{2})Timezone: Z (UTC) or offset like +05:30

Test Examples

InputMatch?
2026-03-15T14:30:00ZMatch
2026-03-15T14:30:00.123ZMatch
2026-03-15T14:30:00+05:30Match
2026-03-15 14:30:00No match
2026-03-15No match

Common Use Cases

  • API timestamp validation
  • Log timestamp parsing
  • Date interchange format verification

Variations

^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$

UTC only (no offset)

Want to test this pattern with your own data?

Open the Regex Tester