Javascript examples for Browser Object Model:Window setInterval
Window setInterval() Method - Display the current time every 1 second, just like a digital watch
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var myVar = setInterval(function(){ myTimer() }, 1000); function myTimer() {/* w ww. ja va2s. c o m*/ var d = new Date(); var t = d.toLocaleTimeString(); document.getElementById("demo").innerHTML = t; } </script> </body> </html>