date_box(), time_box(), datetime_box(), birth_box() form()

Dates and times as groups of select boxes (day, month, year, hour...) that work without JavaScript.

form()->date_box($name = '', $values = [], $extra = [], $replace = [])
form()->time_box($name = '', $values = [], $extra = [], $replace = [])
form()->datetime_box($name = '', $values = [], $extra = [], $replace = [])
form()->birth_box($name = '', $values = [], $extra = [], $replace = [])

Options

OptionMeaning
$nameDefault date, time, datetime, birth.
$valuesYears: 1950-2030 style range, default around the current year.
show_whatOrder of the date parts: ymd (default); datetime_box() takes ymdhis and always adds the time selects after the date.
selectedValue (Y-m-d, H:i:s); default $replace[name].
show_text, translate, add_strEmpty first option; translated month names; attributes of the selects.

Example

Code

return form(['date' => '2026-11-15', 'time' => '09:30:00', 'datetime' => '2026-11-15 09:30:00'])
    ->date_box()
    ->time_box()
    ->datetime_box()
    ->birth_box('birth', '1940-2026');

Notes

  • The parts post as name[year], name[month], name[day]...; join them on the server.
  • The time selects of time_box() come from html()->time_box2() and post time[hour], time[minute], time[second] (fixed 2026-11-15: before, all three posted as time). A posted array shown again selects its parts.
  • datetime_box() renders the date and the time selects (html()->datetime_box2()) and posts datetime[year] ... datetime[second]; a Y-m-d H:i:s value selects every part. Fixed 2026-11-15: before, it rendered only the date selects.

See also: html/date_box2, form/datetime_select, form/html5_inputs