Datetime
- Version
- 3.x
- Updated
A date and time value, rendered as a native <input type="date">.
Storage kind: column · Column: datetime, nullable by default
Use it for any real point in time: a validity window, a scheduled publication, an audit timestamp.
Do not store a date as a string — a varchar date sorts lexically, cannot be
compared in SQL without casting, and has no canonical empty value.
Settings
None of its own. It takes the shared settings only — label, required, default, invisible,
appliesWhen and the storage keys.
There is no JS date widget behind it: the field is a native browser date input, so the picker, the locale formatting and the keyboard behaviour are the browser's. That is why there is nothing to configure and nothing to initialise.
Nullable by default
Alone among the types, this one returns true from getDefaultNullable(). An unset date is
genuinely absent, and the alternative — a zero date — is a sentinel every reader has to recognise
and special-case.
prepareForStorage() enforces it: an empty submitted value becomes SQL NULL, not '' and not
0000-00-00. So "no date" has exactly one representation, and IS NULL is the way to ask.
The audit timestamps (created_at, updated_at) use it, declared 'default' => null and
'invisible' => true: set programmatically, never shown on a form, and NULL until they are stamped.
If you need a date that must always be present, 'nullable' => false plus required works — but be
sure there is a sensible default, because the column then has to hold something before the operator
ever sees the form.
Notes
Those timestamps were 'type' => 'string' on real datetime columns until 2026-07-27, and carried
'visible' => false — a key nothing reads — so they rendered on admin forms despite being declared
hidden. If you have copied that pattern, the working key is invisible.
The column type is datetime, not timestamp: no automatic update on write, no timezone
conversion, and no 2038 limit. Values are stored exactly as given.
@see ../com_configbox_property_definition_settings.md §3