Date Regex Generator & Tester (YYYY-MM-DD, MM/DD/YYYY, ISO 8601)
Build a date or time regex for YYYY-MM-DD, MM/DD/YYYY, DD.MM.YYYY or ISO 8601 with real month lengths and leap years, for JS, PHP, Python, Java and .NET.
[0-9] is used instead of \d, because \d also matches Arabic-Indic and other digits in Python, .NET and some Java modes.
The (?=…) lookahead checks the whole value first; the named groups then pick out the parts. Lookahead works in all five languages.
Leap years follow the Gregorian rule: 2000 and 2024 have 29 February, 1900 and 2023 do not.
| Line | Value | Result | Parts or reason |
|---|---|---|---|
| 1 | 2024-02-29 | Match | year=2024, month=02, day=29 |
| 2 | 2023-02-29 | No match | 2023 is not a leap year |
| 3 | 2026-04-31 | No match | Month 04 has only 30 days |
| 4 | 2026-12-01 | Match | year=2026, month=12, day=01 |
| 5 | 1900-02-29 | No match | 1900 is not a leap year |
| 6 | 2000-02-29 | Match | year=2000, month=02, day=29 |
| 7 | 2026-13-01 | No match | Month 13 does not exist |
| 8 | 26-01-01 | No match | The year must have four digits |
| Part | Rule |
|---|---|
| year | four digits; leap years for 29 February: divisible by 4, but centuries only when divisible by 400 |
| month | 01–12 |
| day | up to 31, 30 or 28/29 depending on the month |
A date regex has to decide how strict to be: \d{4}-\d{2}-\d{2} happily accepts 2026-19-45, while a pattern that knows month lengths and leap years rejects 2023-02-29 but accepts 2024-02-29. This generator writes the pattern for the format you use — ISO 8601, US, European, Korean or compact dates, RFC 3339 date-times or times — at the strictness you choose, with named groups and ready-to-paste code for JavaScript, PHP, Python, Java and C#, then tests it on your values.
How to use this tool
- Choose the date or time format.
- Choose how strict the pattern is; "Real dates" includes leap years.
- Pick the language and whether to validate a whole value or find dates in text.
- Paste test values and check which match and why the others do not.
Formula
leap year = divisible by 4, except centuries, which must be divisible by 400 → (?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:0[048]|[2468][048]|[13579][26])00)
Real dates are built from three month groups — 31 days (01, 03, 05, 07, 08, 10, 12), 30 days (04, 06, 09, 11) and February up to 28 — plus a separate branch for 29 February in leap years. With named groups, a lookahead (?=…) checks the whole value before the groups split it into year, month and day. Patterns use [0-9] rather than \d so that only ASCII digits match in every language. For validation the code uses whole-string matching (test with ^…$, fullmatch, matches, \z), so a trailing line break is not accepted.
Example
With YYYY-MM-DD and "Real dates", the sample list gives 3 matches: 2024-02-29 (2024 is a leap year), 2026-12-01 and 2000-02-29 (2000 is divisible by 400). 2023-02-29 fails because 2023 is not a leap year, 2026-04-31 because April has 30 days, 1900-02-29 because 1900 is a century not divisible by 400, 2026-13-01 because there is no month 13, and 26-01-01 because the year needs four digits.
Frequently asked questions
Should I validate dates with a regex at all?
A regex is good for the format and quick checks in forms or logs. For anything important, also parse the date with your language's date library, which knows time zones and calendar rules.
Why not use \d?
In Python 3, .NET and Java with Unicode flags, \d matches digits from other scripts such as ٣ or ३. [0-9] matches only 0–9.
Does it work for dates in sentences?
Yes — choose "Find dates inside text". The pattern then refuses to match inside longer numbers, so 12026-01-01 is not reported as 2026-01-01.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/date-regex-tool/
Cite or embed this tool
kakaoCalc. (2026, November 8). Date Regex Generator & Tester (YYYY-MM-DD, MM/DD/YYYY, ISO 8601). https://kakao.mobile/tools/date-regex-tool/
“Date Regex Generator & Tester (YYYY-MM-DD, MM/DD/YYYY, ISO 8601).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/date-regex-tool/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms