Date Validation Regex: DD/MM/YYYY Format
• CronOS Team
regexdatevalidationtutorialeuropean-format
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!
Date Validation Regex: DD/MM/YYYY Format
Validate dates in European format (DD/MM/YYYY) with proper month and day range validation using regex.
Pattern Breakdown
regex
^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/\d{4}$
Components
| Component | Description | Matches |
|---|---|---|
^ | Start anchor | Ensures match from string start |
(0[1-9]|[12]\d|3[01]) | Day | 01-31 (zero-padded) |
/ | Separator | Literal forward slash |
(0[1-9]|1[0-2]) | Month | 01-12 (zero-padded) |
/ | Separator | Literal forward slash |
\d{4} | Year | Exactly 4 digits |
$ | End anchor | Ensures match to string end |
Detailed Breakdown
(0[1-9]|[12]\d|3[01])- Day alternation:0[1-9]- Days 01-09[12]\d- Days 10-293[01]- Days 30-31
(0[1-9]|1[0-2])- Month alternation:0[1-9]- Months 01-091[0-2]- Months 10-12
\d{4}- Year: exactly 4 digits
Examples
Valid:
15/03/202401/01/202431/12/202429/02/2024(format valid, but may not be valid date)01/01/0000(format valid)
Invalid:
15/3/2024(month not zero-padded)5/03/2024(day not zero-padded)32/03/2024(invalid day)15/13/2024(invalid month)15-03-2024(wrong separator)2024/03/15(wrong order)
Implementation
JavaScript
javascript
const dateRegex = /^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/;
dateRegex.test('15/03/2024'); // true
dateRegex.test('31/12/2024'); // true
dateRegex.test('32/03/2024'); // false (invalid day)
dateRegex.test('15/13/2024'); // false (invalid month)
Python
python
import re
date_regex = r'^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/\d{4}$'
bool(re.match(date_regex, '15/03/2024')) # True
bool(re.match(date_regex, '31/12/2024')) # True
bool(re.match(date_regex, '32/03/2024')) # False (invalid day)
Go
go
dateRegex := regexp.MustCompile(`^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/\d{4}$`)
dateRegex.MatchString("15/03/2024") // true
dateRegex.MatchString("31/12/2024") // true
dateRegex.MatchString("32/03/2024") // false (invalid day)
Limitations
- No leap year validation: Accepts
29/02/2023(format valid, date invalid) - No month-specific day validation: Accepts
31/04/2024(April has 30 days) - No year range validation: Accepts years like
0000or9999 - Format only: Validates format, not actual date validity
- Ambiguity with MM/DD/YYYY: Can be confused with US format
When to Use
- European date format validation
- UK, Australia, and most international formats
- When day comes before month
- Forms targeting European users
- Date input in DD/MM/YYYY format
For production, consider:
- Additional validation for actual date validity
- Using date parsing libraries to verify dates
- Validating year ranges
- Clearly labeling format to avoid confusion with MM/DD/YYYY
- Combining with date object validation
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!