Regex for Date (ISO 8601 YYYY-MM-DD)
Matches dates in ISO 8601 format (YYYY-MM-DD). The international standard for date representation.
Pattern
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/Pattern Breakdown
| Token | Explanation |
|---|---|
| ^ | Start of string |
| \d{4} | Four-digit year |
| - | Dash separator |
| (0[1-9]|1[0-2]) | Month: 01-12 |
| - | Dash separator |
| (0[1-9]|[12]\d|3[01]) | Day: 01-31 |
| $ | End of string |
Test Examples
| Input | Match? |
|---|---|
| 2026-03-15 | Match |
| 1999-12-31 | Match |
| 2026-13-01 | No match |
| 2026-3-5 | No match |
Common Use Cases
- API date field validation
- Database date parsing
- Log file date extraction
- International date formatting
Variations
^\d{4}-\d{2}-\d{2}$Without month/day range validation
Other Regex Patterns
Want to test this pattern with your own data?
Open the Regex Tester