Dates & Timesflags: g

ISO 8601 Date-Time

Match full ISO 8601 date-times with timezone offset or Z suffix (e.g. 2024-01-15T14:30:00Z).

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+\\-]\\d{2}:?\\d{2})", "g");
const input = "2024-01-15T14:30:00Z";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:?\d{2})   (flags: g)

Raw source: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:?\d{2})

How it works

Date YYYY-MM-DD, literal T, time HH:MM:SS, optional fractional seconds, then either Z or a ±HH:MM / ±HHMM offset.

Examples

Input

2024-01-15T14:30:00Z

Matches

  • 2024-01-15T14:30:00Z

Input

2024-03-01T09:00:00.123+05:30

Matches

  • 2024-03-01T09:00:00.123+05:30

Input

2024-01-15

No match

Common use cases

  • API response parsing
  • Structured log ingestion
  • Audit event timestamp extraction
  • Cross-timezone analytics

Related patterns