ISO 8601 DateTime
intermediateMatches full ISO 8601 datetime strings including time and timezone.
datetimeisotimestamptimezone
Pattern
/\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)/gTry It
0 of 6 strings matched
Explanation
Matches a full ISO 8601 datetime: date (YYYY-MM-DD), literal T, time (HH:MM:SS), optional fractional seconds, and timezone (Z for UTC or ±HH:MM offset).
Test Strings
Matching
- 2024-01-15T09:30:00Z
- 2023-12-31T23:59:59.999+05:30
- 2024-06-15T12:00:00-04:00
Non-matching
- 2024-01-15
- 2024-01-15 09:30:00
- 2024-13-01T00:00:00Z
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /\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;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
Without timezone
\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]\dLocal datetime without timezone offset