Skip to content
uencoder

Regex Date and Time Patterns Reference

Reference for date, time, and ISO 8601 validation regex patterns.

ISO 8601 Patterns

Date only: ^\d{4}-\d{2}-\d{2}$ (YYYY-MM-DD). Date and time: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$ (UTC). With offset: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$. With milliseconds: add .\d{3} before the zone. ISO 8601 also allows week dates (YYYY-Www-D) and ordinal dates (YYYY-DDD). The T separator can be a space by mutual agreement. For full validation including leap years, use Date.parse or a date library, not regex alone.

date
YYYY-MM-DD
ISO 8601
datetime
YYYY-MM-DDTHH:MM:SSZ
UTC
offset
+HH:MM or -HH:MM
timezone

Other Date Formats

US format: ^\d{1,2}/\d{1,2}/\d{4}$ (MM/DD/YYYY). European: ^\d{1,2}\.\d{1,2}\.\d{4}$ (DD.MM.YYYY). Time 12h: ^\d{1,2}:\d{2}(:\d{2})?\s?(AM|PM)$ (case-insensitive). Time 24h: ^([01]\d|2[0-3]):[0-5]\d$ (HH:MM). Duration: ^P\d+Y\d+M\d+DT\d+H\d+M\d+S$ (ISO 8601 duration). Always parse to a Date object for comparison and arithmetic. Be explicit about timezone to avoid off-by-one errors. Store in UTC, display in local time.

US
MM/DD/YYYY
month first
European
DD.MM.YYYY
day first
24h
HH:MM
00-23 hours

Related tools

References