From c0ad7fb49d65884e9bfe2defa165b85715210360 Mon Sep 17 00:00:00 2001 From: Michel Moccand-J Date: Sun, 10 Mar 2024 20:31:39 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=201s=20delay=20for=20countdo?= =?UTF-8?q?wn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index f38f10a..d29a879 100644 --- a/script.js +++ b/script.js @@ -1,7 +1,7 @@ // modifier heure si nécessaire -const endDate = new Date("2024-03-15T20:00:00").getTime(); +const endDate = new Date("2024-03-22T13:00:00").getTime(); -const countdown = setInterval(() => { +const refreshCountdown = () => { const now = new Date().getTime(); const distance = endDate - now; @@ -19,9 +19,7 @@ const countdown = setInterval(() => { document.getElementById("countdown").innerHTML += `

${hours}H

`; document.getElementById("countdown").innerHTML += `

${minutes}M

`; document.getElementById("countdown").innerHTML += `

${seconds}S

`; +} - if (distance < 0) { - clearInterval(countdown); - document.getElementById("countdown").innerHTML ="Le countdown est terminé !"; - } -}, 1000); +setInterval(refreshCountdown, 1000); +refreshCountdown();