-
Notifications
You must be signed in to change notification settings - Fork 2
Datetime
Viames Marino edited this page Feb 26, 2026
·
2 revisions
Pair\Html\FormControls\Datetime renders date-time inputs (datetime-local or custom datetime).
datetimeFormat(string $format): selfmin(string|DateTime $minValue): selfmax(string|DateTime $maxValue): selfvalue(string|int|float|DateTime|null $value): staticrender(): string
- Default format is
Y-m-d\TH:i:s. - Rendered input type is:
-
datetimewhenPost::usingCustomDatetimepicker()is true -
datetime-localotherwise
-
- Constructor may switch format from translation key
FORM_DATETIME_FORMATwhen custom picker is enabled. - With
Env::get('UTC_DATE'),DateTimevalues are converted to current user timezone before formatting.
$publishedAt = (new \Pair\Html\FormControls\Datetime('publishedAt'))
->min('2026-01-01T00:00:00')
->max('2026-12-31T23:59:59')
->value(new DateTime('now'))
->required();
echo $publishedAt->render();Custom format for custom picker:
$eventAt = (new \Pair\Html\FormControls\Datetime('eventAt'))
->datetimeFormat('d/m/Y H:i')
->value(new DateTime('2026-05-20 09:30:00'));See also: Date, Time, FormControl.