types.DateTime type. You can optionally enforce min/max date constraints for validation.
Configuration options
types.DateTime
Minimum allowed date value. Leave empty to skip the validator.
types.DateTime
Maximum allowed date value. Leave empty to skip the validator.
bool
default:"false"
When true, requires the field value to be a non-zero date time.
Validation rules
The date field validates:- Type: Value must be a valid
types.DateTime - Min date: If specified, value must be on or after the minimum date
- Max date: If specified, value must be on or before the maximum date
- Required: If enabled, value cannot be zero (empty)
Go examples
- Basic usage
- With min/max constraints
- Future dates only
- Birth date validation
Database column type
Dates are stored as ISO 8601 formatted strings in the database but handled as
types.DateTime objects in Go.Date format
PocketBase uses ISO 8601 format for dates:Common use cases
Best practices
- Use
types.NowDateTime()for current timestamp - Set appropriate min/max constraints to prevent invalid dates
- For created/updated timestamps, consider using the autodate field instead
- Dates are stored in UTC, plan timezone handling accordingly
- Use
IsZero()to check if a date field is empty
Zero value
The zero value for date fields is a zerotypes.DateTime, which you can check using the IsZero() method.