DateTimeSchemaclass
new DateTimeSchema({ one = "time", title = "Time", input = "datetime-local", ...options }: DateSchemaOptions)| Param | Type | |
|---|---|---|
options | DateSchemaOptions | Options for DateSchema. required |
.value | PossibleDate | Default date used when the input is undefined. readonly |
.min | Nullish<PossibleDate> | Earliest allowed date ( null for no bound). readonly |
.max | Nullish<PossibleDate> | Latest allowed date ( null for no bound). readonly |
.input | DateInputType | HTML <input /> type="" hint for downstream UIs. Defaults to "date" readonly |
.step | number | Rounding step (in milliseconds, because that's the base unit for time). - E.g. 1000 * 60 will round to the nearest minute.- Note: HTML <input> step attributes are in seconds, so you may need to convert units. readonly |
| Return | |
|---|---|
DateTimeSchema | Schema that defines a valid UTC datetime in ISO 8601 format, e.g. 2005-09-12T18:15:00.000Z. |
Schema that defines a valid UTC datetime in ISO 8601 format, e.g. 2005-09-12T18:15:00.000Z.
- The date includes the
Zsuffix to indicate UTC time, this ensures consistent transfer of the date between client and server. - If you wish to define an abstract date without a timezone, e.g. a birthday or anniversary, use
DateSchemainstead. - If you wish to define an abstract time without a timezone, e.g. a daily alarm, use
TimeSchemainstead.
Examples
const schema = new DateTimeSchema({});
schema.validate("2005-09-12T18:15:00Z"); // "2005-09-12T18:15:00.000Z"