How do I set the format of the Datetimepicker


Topic: How do I set the format of the Datetimepicker

maheshbasapur asked 3 years ago

Expected behavior I want user to see the Datetimepicker selected by the Datetimepicker to appear in the form "dd mmm yyyy HH:ii". ie. for eg: 14 Sep 2021 22:30

Actual behavior Default it is showing "14/09/2021, 10:30 PM"

If there is a way to achieve this without javascript code, that would be better.

Resources (screenshots, code snippets etc.)


Michał Duszak staff answered 3 years ago

It's not possible to do it in Datetimepicker without JS. Using JS please use options as follows:

const pickerDateOptions = document.querySelector('#datetimepicker-dateOptions');
new mdb.Datetimepicker(pickerDateOptions, {
    datepicker: { format: "dd mmm yyyy"},
    timepicker: { pmLabel: '', amLabel: ''},
});

https://mdbootstrap.com/snippets/standard/m-duszak/3311907


Lockemann pro premium priority commented 3 years ago

Not working. You have to select the datepicker 2 times to have an output an stil the output is formatted wrong. Locally (MDB5-STANDARD-UI-KIT-Pro-Advanced-3.10.0) I get an error: mdb is not defined (FF v.94.0.2 OSX)


Michał Duszak staff commented 3 years ago

https://mdbootstrap.com/snippets Could you reproduce your code in a snippet?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

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