body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 100px;
}
#timer {
font-size: 3em;
color: #333;
}
Timer Clock in JavaScript
// Get the timer element
const timerElement = document.getElementById(‘timer’);
let hours = 0;
let minutes = 0;
let seconds = 0;
// Function to update the timer
function updateTimer() {
seconds++;
if (seconds == 60) {
seconds = 0;
minutes++;
if (minutes == 60) {
minutes = 0;
hours++;
}
}
// Format the time
const formattedTime =
String(hours).padStart(2, ‘0’) + ‘:’ +
String(minutes).padStart(2, ‘0’) + ‘:’ +
String(seconds).padStart(2, ‘0’);
// Update the timer element
timerElement.textContent = formattedTime;
}
// Update the timer every second
setInterval(updateTimer, 1000);
“`