Javascript examples for Date:getUTCHours
Using getUTCHours(), getUTCMinutes(), and getUTCSeconds() to display the universal time:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function addZero(i) { if (i < 10) { i = "0" + i; }/* w w w . j a v a 2 s. c o m*/ return i; } function myFunction() { var d = new Date(); var x = document.getElementById("demo"); var h = addZero(d.getUTCHours()); var m = addZero(d.getUTCMinutes()); var s = addZero(d.getUTCSeconds()); x.innerHTML = h + ":" + m + ":" + s; } </script> </body> </html>