tool::regex-guide
regex date
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
ISO Date Format Validation (YYYY-MM-DD)
Regex Pattern
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/Flags:
nonePattern Breakdown
^\d{4}4-digit year (e.g. 2024)-Literal hyphen separator(0[1-9]|1[0-2])Month 01–12-Literal hyphen separator(0[1-9]|[12]\d|3[01])Day 01–31$End of stringMatching Examples
✓
2024-01-15✓
2000-12-31✓
1999-06-01Non-Matching Examples
✗
2024-13-01✗
2024-00-15✗
24-01-15✗
2024/01/15Validates dates in ISO 8601 YYYY-MM-DD format. Months are restricted to 01–12 and days to 01–31. Note: logically invalid dates like February 30 must be caught by additional logic.
Language Usage
Common Use Cases
- ▸Validate date input field formats
- ▸Check date format in API query parameters
- ▸Pre-process dates before database insertion
- ▸Clean date columns in CSV files
- ▸Parse dates from log files
Related Patterns
ad · 300×250
// related tools