Date
Format dates with a configurable pattern
Date
The date formatter masks a date string into a fixed pattern as the user types.
Options
| Option | Type | Default | Description |
|---|---|---|---|
pattern | "MM/DD/YYYY" | "DD/MM/YYYY" | "YYYY-MM-DD" | "MM/DD/YYYY" | Output layout |
Usage
validationSchema: {
dob: { format: { type: "date", options: { pattern: "MM/DD/YYYY" } } },
eu: { format: { type: "date", options: { pattern: "DD/MM/YYYY" } } },
}Results
| Typed | Pattern | Result |
|---|---|---|
12252024 | MM/DD/YYYY | 12/25/2024 |
25122024 | DD/MM/YYYY | 25/12/2024 |
20241225 | YYYY-MM-DD | 2024-12-25 |
Things to know
- Only the three patterns above are supported — for anything else, write a custom formatter.
- Pair with the
datevalidator (date: true) for validation.