diff --git a/script.js b/script.js index f9b1a42..797108e 100644 --- a/script.js +++ b/script.js @@ -1,31 +1,31 @@ -const daysEl =document.getElementById ('days'); -const hoursEl =document.getElementById ('hours'); -const minutesEl =document.getElementById ('minutes'); -const secondsEl =document.getElementById ('seconds'); - -const newYears = '1 Jan 2023'; - -function countdown() { - const newYearsDate = new Date(newYears); - const currentDate = new Date(); - - - const totalSeconds = new Date(newYearsDate - currentDate) / 1000; - - const days = Math.floor(totalSeconds / 3600 / 24); - const hours = Math.floor(totalSeconds / 3600) % 24; - const minutes = Math.floor(totalSeconds / 60) % 60; - const seconds =Math.floor(totalSeconds) % 60; - - daysEl.innerHTML = days; - hoursEl.innerHTML = hours; - minutesEl.innerHTML = minutes; - secondsEl.innerHTML = seconds; -} - -//Initial call -countdown(); - -setInterval(countdown, 1000); - - +const daysEl =document.getElementById ('days'); +const hoursEl =document.getElementById ('hours'); +const minutesEl =document.getElementById ('minutes'); +const secondsEl =document.getElementById ('seconds'); + +const newYears = '22 Oct 2022'; + +function countdown() { + const newYearsDate = new Date(newYears); + const currentDate = new Date(); + + + const totalSeconds = new Date(newYearsDate - currentDate) / 1000; + + const days = Math.floor(totalSeconds / 3600 / 24); + const hours = Math.floor(totalSeconds / 3600) % 24; + const minutes = Math.floor(totalSeconds / 60) % 60; + const seconds =Math.floor(totalSeconds) % 60; + + daysEl.innerHTML = days; + hoursEl.innerHTML = hours; + minutesEl.innerHTML = minutes; + secondsEl.innerHTML = seconds; +} + +//Initial call +countdown(); + +setInterval(countdown, 1000); + +