Formify Docs

Date

Format dates with a configurable pattern

Date

The date formatter masks a date string into a fixed pattern as the user types.

Options

OptionTypeDefaultDescription
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

TypedPatternResult
12252024MM/DD/YYYY12/25/2024
25122024DD/MM/YYYY25/12/2024
20241225YYYY-MM-DD2024-12-25

Things to know

  • Only the three patterns above are supported — for anything else, write a custom formatter.
  • Pair with the date validator (date: true) for validation.

On this page