显示效果:

页面代码
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
#clock {
font-size: 160px;
color: white;
}
</style>
</head>
<body>
<div id="clock"></div>
<script>
function updateClock() {
const clockElement = document.getElementById('clock');
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds()+1;
const formattedTime = `${hours.toString().padStart(2, '0')} : ${minutes.toString().padStart(2, '0')} : ${seconds.toString().padStart(2, '0')}`;
clockElement.textContent = formattedTime;
}
updateClock();
setInterval(updateClock, 1000);
</script>
</body>
</html>