Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Execute a Function at Regular Intervals</title> </head> <body> <script> function showTime() { var d = new Date(); document.getElementById("clock").innerHTML = d.toLocaleTimeString(); } setInterval(showTime, 1000); </script> <p>The current time on your computer is: <span id="clock"></span></p> </body> </html>