Skip to content

Commit

Permalink
🩹 Fix 1s delay for countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Kan-A-Pesh committed Mar 10, 2024
1 parent ad28f1e commit c0ad7fb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -19,9 +19,7 @@ const countdown = setInterval(() => {
document.getElementById("countdown").innerHTML += `<p>${hours}<span>H</span></p>`;
document.getElementById("countdown").innerHTML += `<p>${minutes}<span>M</span></p>`;
document.getElementById("countdown").innerHTML += `<p>${seconds}<span>S</span></p>`;
}

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

0 comments on commit c0ad7fb

Please sign in to comment.