.*RegexQuick

Date Format Regex

Regex patterns for validating dates in ISO, US, European, and other formats.

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

About this pattern

Date validation with regex can check format but not logical correctness (February 30 passes the format check). The ISO 8601 pattern above validates YYYY-MM-DD with months 01-12 and days 01-31. For US dates (MM/DD/YYYY), swap the groups. For European dates (DD/MM/YYYY), reverse again. For production systems, parse the date with a date library after format validation to catch impossible dates.

FAQ

Can regex catch invalid dates like Feb 30?

Not easily. Regex can validate the format (correct number of digits, months 01-12, days 01-31) but cannot know which months have 30 vs 31 days or handle leap years. Use date parsing after regex validation.

More patterns