Back to Home

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!

Generate Regex Pattern

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

ComponentDescriptionMatches
^Start anchorEnsures match from string start
(0[1-9]|[12]\d|3[01])Day01-31 (zero-padded)
/SeparatorLiteral forward slash
(0[1-9]|1[0-2])Month01-12 (zero-padded)
/SeparatorLiteral forward slash
\d{4}YearExactly 4 digits
$End anchorEnsures 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-29
    • 3[01] - Days 30-31
  • (0[1-9]|1[0-2]) - Month alternation:
    • 0[1-9] - Months 01-09
    • 1[0-2] - Months 10-12
  • \d{4} - Year: exactly 4 digits

Examples

Valid:

  • 15/03/2024
  • 01/01/2024
  • 31/12/2024
  • 29/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

  1. No leap year validation: Accepts 29/02/2023 (format valid, date invalid)
  2. No month-specific day validation: Accepts 31/04/2024 (April has 30 days)
  3. No year range validation: Accepts years like 0000 or 9999
  4. Format only: Validates format, not actual date validity
  5. 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!

Generate Regex Pattern