ganesh

 

Countdown Timer

// Set the target date (e.g., Christmas Day) const targetDate = new Date("December 25, 2023 00:00:00").getTime(); function updateCountdown() { const currentDate = new Date().getTime(); const timeLeft = targetDate - currentDate; if (timeLeft <= 0) { document.getElementById("timer").innerHTML = "Merry Christmas!"; } else { const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24)); const hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000); const countdownHtml = `${days}d ${hours}h ${minutes}m ${seconds}s`; document.getElementById("timer").innerHTML = countdownHtml; } } setInterval(updateCountdown, 1000); updateCountdown();