ISO 8601 timestamps
A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.
The task
The whole line must match. Match a UTC timestamp like 2025-03-14T09:30:00Z: a date YYYY-MM-DD with a month from 01 to 12 and a day from 01 to 31, the capital letter T, a 24-hour time HH:MM:SS with hours 00 to 23 and minutes and seconds 00 to 59, and a final capital Z.
What this exercise teaches
Long patterns are short ones glued together: the date ranges, a literal T, the time ranges and a literal Z. Each number range is an alternation of digit shapes, like [01]\d|2[0-3] for the hours.
A hint if you get stuck
Reuse the ranges from the date and the 24-hour time exercises, and put the literal T between them and the literal Z at the end.
Try it now, free, no account needed
Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. The worked solution opens once you solve it or after two tries.
Open this exerciseMore exercises in Real-world validation
- US ZIP and ZIP+4Free
- US phone number formatsFree
- Dates YYYY-MM-DDFree
- 24-hour times HH:MMFree
- 12-hour times with AM or PMFree
- Simple email addressesFree
- Web addressesFree
- Hex colorsFree
- IPv4 addresses, 0 to 255Free
- URL slugsFree
- UsernamesFree
- SKU codesFree
- Card numbers in groups of fourFree
- Currency amounts with commasFree
- Decimal numbersFree
- Semantic versionsFree
- MAC addressesFree
- UUIDsFree
- Percentages from 0 to 100Free