document.addEventListener("DOMContentLoaded", function () { const countdownElements = document.querySelectorAll(".svcountdown"); const countdownElements2 = document.querySelectorAll('a[href="#svcountdown"]'); const countdownCodeElements = document.querySelectorAll(".svcountdowncode"); const countdownCodeElements2 = document.querySelectorAll('a[href="#svcountdowncode"]'); countdownCodeElements.forEach((element) => { element.textContent = "SAVE30OFF"; }); countdownCodeElements2.forEach((element) => { element.textContent = "SAVE30OFF"; }); function updateCountdown() { const now = new Date(); const endTime = new Date(); endTime.setHours(endTime.getHours() + 1,0,0,0); //endTime.setDate(endTime.getDate() ); // endTime.setHours(24, 0, 0, 0); const timeLeft = endTime - now; const hours = Math.floor(timeLeft / (1000 * 60 * 60)); const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000); let text = "in "; if (hours > 0) { text += `${hours}h `; } if (minutes > 0) { text += `${minutes}m `; } text += `${seconds}s`; countdownElements.forEach((element) => { element.textContent = text; }); countdownElements2.forEach((element) => { element.textContent = text; }); } updateCountdown(); setInterval(updateCountdown, 1000); });