//g
  • 100% Free
  • No Sign-Up
  • No Credit Card
  • No Free Trial
  • No Pro Tier
  • No Watermarks

Nothing is uploaded. Just open it and start.

Date (YYYY-MM-DD) Regex

An ISO 8601 calendar date: a four-digit year, a month from 01 to 12 and a day from 01 to 31.

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

Piece by piece

  1. ^the start of the text
  2. \d{4}a digit (0–9), repeated exactly 4 times, as many as possible
  3. -the character “-”
  4. (?:a group (not captured)
  5. 0the character “0”
  6. [1-9]one of 1–9
  7. |or
  8. 1the character “1”
  9. [0-2]one of 0–2
  10. )end of the group
  11. -the character “-”
  12. (?:a group (not captured)
  13. 0the character “0”
  14. [1-9]one of 1–9
  15. |or
  16. [12]one of “1”, “2”
  17. \da digit (0–9)
  18. |or
  19. 3the character “3”
  20. [01]one of “0”, “1”
  21. )end of the group
  22. $the end of the text

Examples

TextResult
2026-10-01Matches
1999-12-31Matches
2024-02-29Matches
2026-13-01Doesn't match
2026-1-1Doesn't match
2026-02-32Doesn't match
26-10-01Doesn't match
  • It doesn't know month lengths or leap years: 2026-02-30 matches. Check the date itself after matching.

Other common patterns

Test any regular expression →

Frequently asked questions

How do I use this date (yyyy-mm-dd) regex in JavaScript?
Write it as /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/ and call re.test(text). It is anchored with ^ and $, so it checks the whole text; remove them to find it inside longer text (and add the g flag to find every one). The Code view writes it out for Python, Go and PHP too.
Is it a complete validator?
No regex is the whole story. It doesn't know month lengths or leap years: 2026-02-30 matches. Check the date itself after matching.
Can I try it on my own text?
Yes. The tester above already holds the examples; paste your own text over them and every match is highlighted as you type. Nothing is uploaded.

Spotted a bug or have a suggestion?

Found something broken, have an idea, or just want to say thanks about any of our tools? Every message reaches a real person.