HTML5 Datetime-Local picker unable to alter default value

Im using the HTML5 datetime-local picker and have some custom JS to set the default date/time for me however when trying to use the picker to change the date or time, it doesn’t update the input that contains the original value from JS.

Any ideas?

HTML:

<input id="dt" class="input" type="datetime-local">

JS:

  let dateTime = new Date().toISOString();
  dateTime = dateTime.split(".")[0];
  document.getElementById("dt").value = dateTime;

TIA

2 thoughts on “HTML5 Datetime-Local picker unable to alter default value”

Leave a Comment