Topic: How do I set the format of the Datetimepicker

maheshbasapur free asked 1 year 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 1 year 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 priority commented 1 year 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 1 year 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
Tags