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
| Option | Meaning |
|---|---|
$name | Default date, time, datetime, birth. |
$values | Years: 1950-2030 style range, default around the current year. |
show_what | Order of the date parts: ymd (default); datetime_box() takes ymdhis and always adds the time selects after the date. |
selected | Value (Y-m-d, H:i:s); default $replace[name]. |
show_text, translate, add_str | Empty 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 posttime[hour],time[minute],time[second](fixed 2026-11-15: before, all three posted astime). A posted array shown again selects its parts. datetime_box()renders the date and the time selects (html()->datetime_box2()) and postsdatetime[year]...datetime[second]; aY-m-d H:i:svalue 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