Set input type of datetime-local programmatically

I have a form input field type=datetime-local. I would like to set it to a certain time and have the actual field update to reflect that time.

I have tried:

<input type="datetime-local" class="form-input">

I have tried to set it using the following to test:

document.querySelector(".form-input").value = "1955-05-24T12:15";

I get no errors but the field does not show this date.


Your code worked for me. Make sure the js code run after element created.