DevKits

Dates & Times

Match an ISO 8601 date

Validate or extract ISO 8601 dates like 2025-06-15.

Pattern

Regular expression

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])

How it works

4-digit year, month (01–12), day (01–31). Does not check for months with 30 vs 31 days, or leap years — for strict validation, parse the date and compare.

Matches

  • 2025-06-15
  • 2000-02-29
  • 1999-12-31

Non-matches

  • 2025-13-01 (bad month)
  • 2025-06-32 (bad day)
  • 25-06-15 (short year)

Language snippets

JavaScript

const re = /\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])/g;

Python

re.findall(r"\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])", text)

Go

re := regexp.MustCompile(`\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])`)

Java

Pattern.compile("\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])")

Related patterns

Try any pattern live in the Regex Tester