Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to display the time.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function addZero(i) { if (i < 10) { i = "0" + i; } return i; } function myFunction() { var d = new Date(); var x = document.getElementById("demo"); var h = addZero(d.getHours()); var m = addZero(d.getMinutes()); var s = addZero(d.getSeconds()); x.innerHTML = h + ":" + m + ":" + s; } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_datetime by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:26:55 GMT --> </html>
Result:
Try it Yourself - © w3schools.com