Skip to content

Regex for Date (MM/DD/YYYY)

This regex matches dates in the US-style MM/DD/YYYY format with forward slash separators. It validates that months are 01-12 and days are 01-31. This format is commonly used in US-facing applications, government forms, and legacy systems. For international or API use, prefer the ISO 8601 YYYY-MM-DD format instead.

Pattern
^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$
Test this pattern in the Regex Tester →

What is the regex pattern for Date (MM/DD/YYYY)?

The regex pattern for Date (MM/DD/YYYY) is ^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$. This regex matches dates in the US-style MM/DD/YYYY format with forward slash separators. It validates that months are 01-12 and days are 01-31. This format is commonly used in US-facing applications, government forms, and legacy systems. For international or API use, prefer the ISO 8601 YYYY-MM-DD format instead. This pattern is commonly used for us date form validation and legacy system integration.

Test Examples

Match
01/15/2024
Matches: 01/15/2024
Match
12/31/2023
Matches: 12/31/2023
No Match
13/01/2024

Common Uses

Variations

With dashes

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

Uses dashes instead of slashes

Optional leading zeros

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

Allows 1/5/2024 instead of requiring 01/05/2024

Two-digit year

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

Matches MM/DD/YY with two-digit year

Frequently Asked Questions

Why prefer YYYY-MM-DD over MM/DD/YYYY?

YYYY-MM-DD (ISO 8601) is internationally unambiguous and sorts correctly as a string. MM/DD/YYYY is only used in the US and can be confused with DD/MM/YYYY used in Europe. Use ISO 8601 for APIs and storage.

How do I handle both MM/DD/YYYY and DD/MM/YYYY?

You cannot distinguish between these formats by regex alone for dates like 03/04/2024. You need to know the expected format from context, locale settings, or user preference.

Does this validate February 29 in leap years?

No. Regex cannot perform the arithmetic needed for leap year validation. Parse the matched date and validate it programmatically.

Related Patterns

Date (YYYY-MM-DD)

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

ISO 8601 DateTime

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

24-Hour Time

^([01]\d|2[0-3]):([0-5]\d)$

Related Reading

Regex Cheat Sheet with Examples for Developers → URL Encoding Special Characters →