Datetimepicker logo Datetimepicker

Reference

constructor Object: config, Boolean: initialize

Datetimepicker uses Modi and Calendar packages, so the config object merges the configuration of both.

Config structure:

config = {
  {Modi config},
  calendar: {Calendar config},
  minDate: {String|Number|Date},
  maxDate: {String|Number|Date},
  selectedDate: {String|Number|Date}
}

Default config:

config = {
  eventsNamespace: 'dtp',
  template: <defaultTemplate>,
  minDate: null,
  maxDate: null,
  selectedDate: new Date(),
  calendar: {
    week: {
      namesType: 'mini'
    }
  }
}

Datetimepicker extends Modi, so, in addition to the following properties, methods and events, those offered by the base class are also available.

Properties

calendar Calendar

Calendar instance.

selectedDate Date

Default selected date.

hoursRange Array

Hours range.

minutesRange Array

Minutes range.

Methods

changeMonth Date: date

Change selected month.

refreshCalendar

Redraw calendar.

setSelectedDay String|Number|Date: day, Boolean: changeMonth

Set selected day.

setLimitDate String: type, String|Number|Date: date, Boolean: refresh

Set calendar limits.

getDayElementByDate String|Number|Date: date Element|undefined

Get day element by date.

getSelectedDayDate mixed: def Date|mixed

Get selected day.

getHours Number

Get selected hour.

getMinutes Number

Get selected minutes.

parseDate String|Number|Date: date, mixed: def Date|mixed

Parse date.

isValidDate mixed: operand Boolean

Check for a valid date object.

Events

Dispatched events have the detail property, which contains:

datetimepicker.addListener('dtp:day:click', (e) => {
  console.log(e.detail.instance);
});

day:click

Dispatched when a day element is clicked.

detail +=

month:change

Dispatched when the current month changes.

detail +=

action:click

Dispatched when an action button is clicked.

detail +=