ErlangFormDocs v1.0.0
Basic fields

Date and time

ISO strings, local Date objects, and UTC datetime storage.

SchemaInputValue after editing
z.iso.date()dateYYYY-MM-DD string
z.iso.time()timeBrowser time string
z.iso.datetime()datetime-localUTC ISO string; clearing produces undefined
z.date()dateDate at local midnight; clearing produces undefined

Usage

Use your form instance from useForm. See the initial setup.

example.tsx
const schema = z.object({
  day: z.iso.date(),
  time: z.iso.time(),
  birthday: z.date().optional(),
  meeting: z.iso.datetime().optional(),
});

<ErlForm
  form={form}
  schema={schema}
/>

Clearing a date/time string produces an empty string. optional() only accepts undefined, so explicitly allow or normalize empty strings when appropriate.

z.date() preserves the local calendar date. Avoid using toISOString().slice(0, 10) to format a local date, because UTC conversion can change the day. Convert Date values received through JSON back to Date objects before initializing form state.

Datetime is displayed in local time and saved as UTC when edited. For example, 09:00 in Jakarta becomes 02:00Z on the same date. Align time-schema precision with the browser value, especially when seconds are required.

min, max, and step are not forwarded to built-in date/time inputs in 1.0.0. Use schema validation and a custom component when these browser attributes are needed.

On this page