Javascript examples for DOM HTML Element:Input Datetime
The value property sets or gets the value attribute of a datetime field, which controls date and time for the datetime field.
Set the value property with the following Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD | Sets the date and/or time. |
A String, representing the date and time of the datetime field
The following code shows how to Set a date and time for a datetime field:
<!DOCTYPE html> <html> <body> Date: <input type="datetime" id="myDatetime" value="2018-02-06T10:57Z"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . j a va2s . c o m*/ document.getElementById("myDatetime").value = '2018-03-06T10:57Z'; var x = document.getElementById("myDatetime").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>