Javascript examples for DOM HTML Element:Input Datetime Local
The value property sets or gets the value attribute of a local datetime field, which controls a local date and time for the datetime field.
Set the value property with the following Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ss.ms | Sets the date and time. |
A String, representing the date and time of the local datetime field
The following code shows how to Set a local date and time for a datetime field:
<!DOCTYPE html> <html> <body> <input type="datetime-local" id="myLocalDate" value="2018-11-16T15:25:33"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w.jav a2 s. co m document.getElementById("myLocalDate").value = '2028-11-16T15:25:33'; var x = document.getElementById("myLocalDate").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>