<!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