datetime_select() form()

A date and / or time picker field: eonasdan (default), native inputs, flatpickr or Tempus Dominus, with limits and a format.

form()->datetime_select($name = '', $desc = '', $extra = [], $replace = [])

Options

OptionMeaning
pickereonasdan (bootstrap-datetimepicker 4.17, jQuery + moment), native, flatpickr or tempus; default yf_form2_datetime::$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.
configflatpickr / tempus options over yf_form2_datetime::$CONFIG.
value, selectedA timestamp, a DB value or d.m.Y text.

Example

Code

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']);

Notes

  • 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).

Bootstrap 3 and 5

eonasdan needs the Bootstrap 3 JavaScript glyph markup and works under the bs5 compat layer; tempus uses Popper and Bootstrap 5 styles.

See also: form/daterange, form/html5_inputs, demo:form/datetime_pickers