Dates & Timesflags: g
ISO 8601 Date
Match dates in ISO 8601 format: YYYY-MM-DD with valid month (01–12) and day (01–31) ranges.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) (flags: g)Raw source: \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
How it works
Year is any 4-digit number. Month uses alternation to enforce 01-12. Day enforces 01-31, though it won't catch month-specific overflows (e.g. Feb 30).
Examples
Input
2024-01-15Matches
2024-01-15
Input
1999-12-31Matches
1999-12-31
Input
2024-13-01No match
—Common use cases
- •Log file timestamp extraction
- •API response date validation
- •Database query parsing
- •Data migration scripts
Related patterns
European Date Format (DD/MM/YYYY)
Dates & TimesMatch European-style dates in DD/MM/YYYY format with valid day (01–31) and month (01–12) ranges.
ISO 8601 Date-Time
Dates & TimesMatch full ISO 8601 date-times with timezone offset or Z suffix (e.g. 2024-01-15T14:30:00Z).
US Date Format (MM/DD/YYYY)
Dates & TimesMatch US-style dates in MM/DD/YYYY format with range validation.
24-Hour Time
Dates & TimesMatch 24-hour time formats HH:MM or HH:MM:SS with valid hour (00–23) and minute/second (00–59) ranges.