Topic: Set Datetimepicker dynamically

ppt premium asked 2 years ago

Expected behavior

I would expect to be able to set the value from javascript, using something like follows:

let date = new Date('2022-07-10T13:24:00');
document.getElementById('myDateTime').value = date;

When I click to change the value, then the currently selected date/time should match this value.

Actual behavior

Although this displays something in the input box, when I click to change the value there is no currently selected date or time in the popup dialog.

Resources (screenshots, code snippets etc.)

I have also tried setting the value using the locale-specific string format used, to no avail. Any help greatly received!

Dawid Wajszczuk staff answered 2 years ago


You need to dispose datetimepicker and then reinitialize it with new date and new time. Here is the snippet

Keep coding,

ppt premium answered 2 years ago

That really helps - many thanks Dawid!

Please insert min. 20 characters.


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



Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.2
  • Device: Desktop
  • Browser: Edge
  • OS: Win10
  • Provided sample code: No
  • Provided link: No