datetime_select() form()
A date and / or time picker field: eonasdan (default; Tempus Dominus on Bootstrap 5), native inputs, flatpickr or Tempus Dominus, with limits and a format.
form()->datetime_select($name = '', $desc = '', $extra = [], $replace = [])Опції
| Опція | Значення |
|---|---|
picker | eonasdan (bootstrap-datetimepicker 4.17, jQuery + moment), native, flatpickr or tempus; default yf_form2_datetime::$PICKER (eonasdan), on Bootstrap 5 pages $PICKER_BS5 (tempus; empty: $PICKER). |
with_time, no_date, no_time | Add the time; time only; date only. |
format | PHP date() format of the field; default d.m.Y (with time d.m.Y H:i). |
min_date, max_date, default_date, disabled_dates | Timestamps or dates; native cannot disable single dates (falls back to eonasdan with a notice). |
stepping, side_by_side | Minutes step; date and time side by side. |
inline | flatpickr / tempus: the calendar stays open under the field instead of a popup. |
config | flatpickr / tempus options over yf_form2_datetime::$CONFIG. |
value, selected | A timestamp, a DB value or d.m.Y text. |
Приклад
Код
return form(['starts' => '2026-11-15 10:00:00'])
->datetime_select('starts', 'Starts', ['with_time' => 1, 'stepping' => 15])
->datetime_select('due', 'Due date', ['picker' => 'flatpickr', 'min_date' => '2026-11-01', 'max_date' => '2026-12-31'])
->datetime_select('day', 'Day (native)', ['picker' => 'native']);Примітки
nativeposts ISO (Y-m-d,Y-m-d\TH:i,H:i); the other pickers post the field format, as the table2 filtersdt_*read it.- flatpickr loads its dark stylesheet under a Bootstrap 5 dark colour mode (
yf_form2_datetime::$DARK); Tempus Dominus takes the colours of the colour mode. - Since 3.9.0 a field without the
pickeroption is Tempus Dominus on Bootstrap 5 pages (eonasdan before; same posted value). Site scripts using the eonasdan jQuery API there set$PICKER_BS5toeonasdanor pass the option.
Bootstrap 3 and 5
Bootstrap 5 default: tempus (Popper, Bootstrap 5 styles, light / dark). eonasdan needs the Bootstrap 3 JavaScript glyph markup and still works under the bs5 compat layer.
Див. також: form/daterange, form/html5_inputs, demo:form/datetime_pickers