setInterval(function horarioAtual() { let hora = new Date().toLocaleTimeString(); document.getElementById("rel").innerHTML = hora; }, 1000)
<!DOCTYPE html> <html> <head> <title>Parcel Sandbox</title> <meta charset="UTF-8" /> </head> <body> <p>Relógio Digital - horário atual.</p> <h2 id="rel"></h2> <script src="src/index.js"></script> </body> </html>