DEV Community

Discussion on: Digital Clock Using HTML, CSS & JS.

Collapse
lukeshiru profile image
LUKESHIRU

With modern JS it could look something like this:

setInterval(
    () =>
        (document.getElementById("time").textContent =
            new Date().toLocaleTimeString()),
    1e3
);
Enter fullscreen mode Exit fullscreen mode

Also, ideally, you could use classnames instead of ids, so you can update multiple elements with the same classname instead of just one :D

Cheers!