From 4f05f739e0647fcaa12db7a75da6e02bdea89540 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Mon, 25 Jan 2021 13:03:59 -0500 Subject: [PATCH] Show clock immediately Previous code had 1-second delay. --- fr/index.html | 9 ++++++--- index.html | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fr/index.html b/fr/index.html index 902e5d3..698168c 100644 --- a/fr/index.html +++ b/fr/index.html @@ -49,8 +49,7 @@ // Set the date we're counting down to var countDownDate = new Date("Jan 30, 2021 14:00:00").getTime(); - // Update the count down every 1 second - var x = setInterval(function() { + function updateClock() { // Get today's date and time var now = new Date().getTime(); @@ -86,6 +85,10 @@ clearInterval(x); document.getElementById("clock").innerHTML = "Le mariage commence maintenant !"; } - }, 1000); + } + + // Update the count down every 1 second + updateClock(); + setInterval(updateClock, 1000); diff --git a/index.html b/index.html index 8eb71aa..371c568 100644 --- a/index.html +++ b/index.html @@ -48,8 +48,7 @@ // Set the date we're counting down to var countDownDate = new Date("Jan 30, 2021 14:00:00").getTime(); - // Update the count down every 1 second - var x = setInterval(function() { + function updateClock() { // Get today's date and time var now = new Date().getTime(); @@ -73,6 +72,10 @@ clearInterval(x); document.getElementById("clock").innerHTML = "The wedding will start ASAP!"; } - }, 1000); + } + + // Update the count down every 1 second + updateClock(); + setInterval(updateClock, 1000);