// Date limite = dimanche à minuit const deadline = new Date(); const now = new Date(); const day = now.getDay(); // 0 = dimanche const daysUntilSunday = (7 - day) % 7; deadline.setDate(now.getDate() + daysUntilSunday); deadline.setHours(23, 59, 59, 999); function updateCountdown() { const now = new Date(); const diff = deadline - now; if (diff <= 0) { document.getElementById("countdown").innerText = "offre terminée"; return; } const days = Math.floor(diff / (1000 * 60 * 60 * 24)); const hours = Math.floor((diff / (1000 * 60 * 60)) % 24); const minutes = Math.floor((diff / (1000 * 60)) % 60); const seconds = Math.floor((diff / 1000) % 60); document.getElementById("countdown").innerText = `${days}j ${hours}h ${minutes}min ${seconds}s restants`; } setInterval(updateCountdown, 1000); updateCountdown(); // appel initial