Change the date and time of a <time> element:
document.getElementById("myTime").dateTime = "1999-06-24T09:30Z";
Click the button to change the value of the datetime attribute of the time element.
The time element is supported by any of the major browsers.
The dateTime property is only supported in Firefox and Opera 12.
<!DOCTYPE html> <html> <body> <p>Date <time id="myTime" datetime="2020-02-14T08:00Z">Valentines day</time>.</p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*www .j a v a 2s.c om*/ document.getElementById("myTime").dateTime = "1999-06-24T09:30Z"; document.getElementById("demo").innerHTML = "The date and time was changed."; } </script> </body> </html>