This library adds additional types for Zod to parse and validate dates, times and durations as
Temporal types. This library has support for both zod/v4
and zod/v4/mini
.
Install via your favorite package manager:
npm install zod-temporal
# or
pnpm add zod-temporal
# or
yarn add zod-temporal
Import the schema types from this package. You can either import individual types or import all types via convenience method:
import {zt} from 'zod-temporal';
For zod/v4/mini
, import from the mini sub-path:
import {zt} from 'zod-temporal/mini';
This library supplies the following types:
zj.duration()
zj.plainDate()
zj.plainDateTime()
zj.plainTime()
zj.offsetDateTime()
zj.zonedDateTime()
In contrast to zod-joda, zj.zonedDateTime()
represents date times with timezone information, while
zj.offsetDateTime()
also parses to a Temporal.ZonedDateTime
but cast to UTC.