T
ToolPrime

Regex for Date (DD/MM/YYYY)

Validates dates in DD/MM/YYYY format with basic day/month range checking.

Pattern

/^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/

Live Tester

Enter a string to test

Examples

15/01/2024
31/12/2023
01/06/2000
32/01/2024
15/13/2024
1/6/2000

Pattern Breakdown

^(0[1-9]|[12]\d|3[01]) — day 01-31

\/ — literal forward slash

(0[1-9]|1[0-2]) — month 01-12

\/\d{4}$ — slash + four-digit year

Code Snippets

Javascript

const regex = /^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/;
regex.test("15/01/2024"); // true

Python

import re
pattern = r"^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/\d{4}$"
bool(re.match(pattern, "15/01/2024"))  # True

Php

$pattern = '/^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/';
preg_match($pattern, "15/01/2024"); // 1

Related Patterns

Frequently Asked Questions

What is the regex for Date (DD/MM/YYYY)?
The regex pattern for Date (DD/MM/YYYY) is /^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/. Validates dates in DD/MM/YYYY format with basic day/month range checking.
How do I use the Date (DD/MM/YYYY) regex in JavaScript?
In JavaScript you create the pattern with a regex literal or the RegExp constructor and call .test() to check a string against it. A ready-to-copy example is shown in the Code Snippets section above, alongside Python and PHP versions.
What does the Date (DD/MM/YYYY) pattern match?
It matches strings like 15/01/2024; it rejects strings like 32/01/2024. See the Examples section above for the full list of matching and non-matching cases.

Related Tools