Skip to main content
CalcHive

Regex for Date (ISO 8601 YYYY-MM-DD)

Matches dates in ISO 8601 format (YYYY-MM-DD). The international standard for date representation.

Pattern

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

Pattern Breakdown

TokenExplanation
^Start of string
\d{4}Four-digit year
-Dash separator
(0[1-9]|1[0-2])Month: 01-12
-Dash separator
(0[1-9]|[12]\d|3[01])Day: 01-31
$End of string

Test Examples

InputMatch?
2026-03-15Match
1999-12-31Match
2026-13-01No match
2026-3-5No match

Common Use Cases

  • API date field validation
  • Database date parsing
  • Log file date extraction
  • International date formatting

Variations

^\d{4}-\d{2}-\d{2}$

Without month/day range validation

Want to test this pattern with your own data?

Open the Regex Tester