Basic Usage
Type Signature
string | $ZodDateParams
Optional error message (string) or configuration object
Behavior
z.date() only accepts JavaScript Date objects. It does NOT accept:
- Timestamps (numbers)
- Date strings
- Other date representations
Validation Methods
.min()
Enforces a minimum date/time.
number | Date
required
Minimum date (as Date object or timestamp)
string | $ZodCheckGreaterThanParams
Custom error message
.max()
Enforces a maximum date/time.
number | Date
required
Maximum date (as Date object or timestamp)
string | $ZodCheckLessThanParams
Custom error message
Properties
.minDate (Deprecated)
Returns the minimum date constraint as a Date object, or null if not set.
.maxDate (Deprecated)
Returns the maximum date constraint as a Date object, or null if not set.
Common Use Cases
Date Range Validation
Future Dates Only
Past Dates Only
Birth Date Validation
Type Coercion
To accept date strings or timestamps and convert them to Date objects:Preprocessing
For custom date parsing logic:ISO Date Strings
For validating ISO 8601 date strings, use the ISO schemas:Refinements
For complex date logic:Chaining
TypeScript Type
See Also
- z.iso.date() - ISO 8601 date strings
- z.iso.datetime() - ISO 8601 datetime strings
- z.iso.time() - ISO 8601 time strings
- z.coerce.date() - Date with type coercion
- Refinements - Custom validation logic