Цю сторінку ще не перекладено українською, тому нижче англійська версія.

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 = [])

Опції

ОпціяЗначення
pickereonasdan (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_timeAdd the time; time only; date only.
formatPHP date() format of the field; default d.m.Y (with time d.m.Y H:i).
min_date, max_date, default_date, disabled_datesTimestamps or dates; native cannot disable single dates (falls back to eonasdan with a notice).
stepping, side_by_sideMinutes step; date and time side by side.
inlineflatpickr / tempus: the calendar stays open under the field instead of a popup.
configflatpickr / tempus options over yf_form2_datetime::$CONFIG.
value, selectedA 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']);

Примітки

  • native posts ISO (Y-m-d, Y-m-d\TH:i, H:i); the other pickers post the field format, as the table2 filters dt_* 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 picker option is Tempus Dominus on Bootstrap 5 pages (eonasdan before; same posted value). Site scripts using the eonasdan jQuery API there set $PICKER_BS5 to eonasdan or 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