Regex tester / pattern library
Regex: date (yyyy-mm-dd)
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/ Test it live How it works
ISO 8601 calendar date: four-digit year, month constrained to 01–12, day to 01–31. Leading zeros required, as ISO specifies.
Honest caveats
Does not know calendars: 2026-02-31 passes the format check. Validate real dates by parsing — in JS, check the Date round-trips to the same string.
Matches
2026-08-301999-12-312000-02-29
Doesn't match
2026-13-012026-08-3226-08-302026/08/30