100% Client-Side β’ 0 B Data Leaves Browser
formatting
ISO 8601 Date (YYYY-MM-DD) Regex
Matches standard ISO year-month-day calendar dates.
Regular Expression Pattern:
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
Valid Match Example:
2026-09-04
Invalid / Non-Match Example:
2026-13-45
Regex Syntax Breakdown & Explanation
- β’^\d{4} : 4-digit year
- β’-(0[1-9]|1[0-2]) : Month between 01 and 12
- β’-(0[1-9]|[12]\d|3[01])$ : Day between 01 and 31
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
const isValid = regex.test("2026-09-04");
console.log(isValid); // truePython (re)
import re
pattern = r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$"
match = re.match(pattern, "2026-09-04")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$`)
fmt.Println(re.MatchString("2026-09-04"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/. Matches standard ISO year-month-day calendar dates.