days
hours
minutes
seconds
function startCountdown(endTime) {
function updateCountdown() {
let now = new Date().getTime();
let timeLeft = endTime - now;
if (timeLeft <= 0) {
document.getElementById("countdown-timer").innerHTML = "Time is up!";
clearInterval(timer);
return;
} let days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
let hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((timeLeft % (1000 * 60)) / 1000); document.getElementById("days").innerText = days;
document.getElementById("hours").innerText = hours;
document.getElementById("minutes").innerText = minutes;
document.getElementById("seconds").innerText = seconds;
} updateCountdown(); // Run immediately
let timer = setInterval(updateCountdown, 1000);
} // Set the countdown target date (YYYY, MM (0-based), DD, HH, MM, SS)
let countdownDate = new Date(2025, 3, 21, 23, 59, 59).getTime(); // Change this to your target date
startCountdown(countdownDate);
#countdown-timer {
font-size: 20px;
font-weight: bold;
color: red;
text-align: center;
margin-top: 10px;
}