14 patterns
Date & Time Validation Regex Patterns
Date validation with regex handles format checking - it doesn't verify calendar correctness (e.g., Feb 31). Combine these patterns with a date parsing library for full validation. These patterns cover the most common international and regional formats.
Common Use Cases
All Date & Time Validation Patterns
French Date Format
DD/MM/YYYY format (e.g., 25/12/2023).
^(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20)\d{2}$ISO 8601 Date
YYYY-MM-DD format (e.g., 2023-12-25).
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$US Date Format
MM/DD/YYYY format (e.g., 12/25/2023).
^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12][0-9]|3[01])\/(?:19|20)\d{2}$ISO Date and Time
Full ISO 8601 DateTime with timezone.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)?$24h Time HH:MM
Strict 24h time format (00:00 to 23:59).
^(?:[01]\d|2[0-3]):[0-5]\d$12-Hour Time Format
Validates 12-hour time format with AM/PM.
^(0?[1-9]|1[0-2]):[0-5][0-9]\s?(AM|PM|am|pm)$Date DD/MM or MM/DD
DD/MM/YYYY or MM/DD/YYYY format (no calendar validation).
^\d{2}\/\d{2}\/\d{4}$Time 24-hour Format
Validates time in HH:MM or HH:MM:SS 24-hour format.
^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$Unix Timestamp (seconds)
Matches a 10-digit Unix epoch timestamp in seconds (1973–2286 range).
^\d{10}$Unix Timestamp (milliseconds)
Matches a 13-digit JavaScript-style Unix timestamp in milliseconds.
^\d{13}$ISO 8601 Datetime (with timezone)
Validates a full ISO 8601 datetime string with timezone (UTC Z or ±hh:mm). Standard for APIs.
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})$ISO Year-Month
Validates an ISO 8601 year-month string (YYYY-MM).
^\d{4}-(?:0[1-9]|1[0-2])$ISO Year-Week
Validates an ISO 8601 year-week date (YYYY-Www, weeks 01-53).
^\d{4}-W(?:0[1-9]|[1-4]\d|5[0-3])$ISO 8601 Duration
Validates ISO 8601 duration strings (e.g. PT1H30M, P1Y2M3DT4H5M6S).
^P(?!$)(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?=\d)(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$Frequently Asked Questions
Does regex validate that a date is real (e.g., no Feb 31)?
No. Regex checks format only. Use new Date() or a library like date-fns to verify calendar correctness.
What is ISO 8601 date format?
YYYY-MM-DD (e.g., 2024-12-31). It's the international standard and recommended for APIs and databases.
How do I validate 24-hour time?
Use the "Time 24-hour Format" pattern: ^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$
Looking for patterns in other categories?
Browse all 250 patterns