const targetDate = new Date("June 14, 2024 00:00:00").getTime(); function updateCountdown() { const now = new Date().getTime(); const timeLeft = targetDate - now; if (timeLeft < 0) { clearInterval(countdownInterval); document.getElementById("timer").textContent = "Time's up!"; document.getElementById("message").textContent = "The target date has been reached."; return; } 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); document.getElementById("timer").textContent = `${days.toString().padStart(2, "0")}:${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`; } const countdownInterval = setInterval(updateCountdown, 1000); updateCountdown();