Date & Time Fields
Capture dates, times and datetimes with validation for ranges and custom formatting.
Overview
Polyform includes three temporal field types: date for date selection, datetime for combined date and time and time for time-only inputs. All three are validated by the DateFieldValidator and support min/max constraints and custom formatting.
Date Field
Use addDate() to add a date picker. You can restrict the selectable range with min_date and max_date.
app/Actions/CreateEventForm.php
DateTime Field
addDateTime() creates a combined date and time picker, useful for appointments, bookings and scheduled events.
app/Actions/CreateBookingForm.php
Time Field
addTime() gives you a time-only input when you don't need a date.
app/Actions/CreateScheduleForm.php
Available Settings
Format Defaults
Default formats are:
Y-m-d for date, Y-m-d H:i for datetime, and H:i for time. These follow PHP date format conventions. Validation
The DateFieldValidator checks:
- Valid date/time format matching the field's configured format
- Date is not before
min_date(if set) - Date is not after
max_date(if set) - Required/optional status based on field configuration
Timezone Considerations
Date and time values are stored as strings in the configured format. If you need timezone-aware handling, convert the values in your application code after submission.