How do I set start and end date-limits to Datetimepicker


Topic: How do I set start and end date-limits to Datetimepicker

maheshbasapur pro premium asked 4 months ago

Expected behavior I should be able to set upper / lower / both-upper-and-lower limit to Datetimepicker

When set, I should not be able to select dates below lower limit and above upper limit

Actual behavior Have no idea how to do it. Documentation seem to be non-existentant

Resources (screenshots, code snippets etc.)


Michał Duszak staff answered 4 months ago

You are able. Datetimepicker documentation says that Datepicker and Timepicker options works only with JS initialization. https://mdbootstrap.com/docs/standard/forms/datetimepicker/#section-dateTime-options

Options for each Datepicker and Timepicker are listed on according documentation pages:

https://mdbootstrap.com/docs/standard/forms/datepicker/ https://mdbootstrap.com/docs/standard/forms/timepicker/

Example on how to set ranges on hour and dates:

const pickerDateOptions = document.querySelector('#datetimepicker-dateOptions');
new mdb.Datetimepicker(pickerDateOptions, {
    datepicker: { min: new Date(2021, 8, 10), max: new Date(2021, 8, 20)},
    timepicker: { minHour: 6, maxHour: 12},
});

https://mdbootstrap.com/snippets/standard/m-duszak/3311829#js-tab-view


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: mackbook
  • Browser: safari
  • OS: Mac
  • Provided sample code: No
  • Provided link: No