Skip to content
doubtly

1 answer

Best answer

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Digital Clock</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            text-align: center;
            margin: 100px;
            font-size: 2em;
        }
    </style>
</head>
<body>

<div id="digitalClock"></div>

<script>
    function updateClock() {
        const now = new Date();
        const timeString = now.toTimeString().slice(0, 8);
        document.getElementById("digitalClock").innerHTML = timeString;
    }

    setInterval(updateClock, 1000);
    updateClock(); // Display the clock immediately
</script>

</body>
</html>
Output https://youtu.be/1lkwHZKbFng
Doubtly · 18 Nov 2023 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.