Use MDB custom Datetimepicker component to select date and time.
Note: Read the API tab to find all available options and advanced customization
You can use inline version with option data-mdb-inline.
You can set default date and time with options defaultDate and
defaultTime.
Add data-mdb-ivalid-label with specified value, to change the
invalid label message.
Add data-mdb-toggle="datetimepicker" to the input element to enable
toggling on input click. It is also possible to set
toggleButton option to false to remove the toggle
button.
Use datepicker or timepicker option to set custom
options from our Datepicker and Timepicker components.
Note: This options works only with JS initialization.
const pickerDateOptions = document.querySelector('#datetimepicker-dateOptions');
new mdb.Datetimepicker(pickerDateOptions, {
datepicker: { format: 'dd-mm-yyyy'},
});
Note: This options works only with JS initialization.
const pickerTimeOptions = document.querySelector('#datetimepicker-timeOptions');
new mdb.Datetimepicker(pickerTimeOptions, {
timepicker: { format24: true },
});
Via data attributes or JavaScript, the datetimepicker plugin allows to select a date and time and show it on the selected output.
Add class datetimpicer to your selected wrapper with input. It
automaticly set datetimepicker to this element. Datetimepicker will be toggling
with click event on this container.
Add data-toggle="datetimepicker" to a input or selected element
like button.
Via JavaScript plugin required a class or ID wrapper element with
datetimepicker class.
var myDatetimepicker = new mdb.Datetimepicker(document.getElementById('wrapper-id'))
Options can be passed via data attributes or JavaScript. For data attributes,
append the option name to data-datetimepicker-, as in
data-datetimepicker-inline.
| Name | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false |
Set a disabled attribute to input in wrapper |
| inline | boolean | false |
Allows to use a inline version of timepicker |
| defaultDate | string|date|number | '22/11/2020' |
Allows to set default date |
| defaultTime | string|date|number | '1:56 AM' |
Allows to set default time |
| datepicker | object | { format: 25-12-2020 } |
Allows to set datepicker options |
| timepicker | object | { format24: true } |
Allows to set timepicker options |
| Name | Description | Example |
|---|---|---|
dispose
|
Destroy datetimepicker with this method |
datetimepicker.dispose()
|