API reference / @evolu/common / Type / DateIso

Variable: DateIso

const DateIso: TransformType<InstanceOfType<DateConstructor>, BrandType<Type<"String", string, string, StringError, string, StringError>, "DateIso", DateIsoStringError, StringError>, DateIsoStringError>;

Defined in: packages/common/src/Type.ts:2005

Transforms a Date into a DateIsoString string and vice versa.

Example

DateIso.from(new Date("2023-12-25T10:30:00.000Z")); // ok("2023-12-25T10:30:00.000Z")
DateIso.to("2023-12-25T10:30:00.000Z"); // Date object
DateIso.from(new Date("invalid")); // err({ type: "DateIsoString", value: "Invalid Date" })

Was this page helpful?