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-30
  • 1999-12-31
  • 2000-02-29

Doesn't match

  • 2026-13-01
  • 2026-08-32
  • 26-08-30
  • 2026/08/30

More patterns