Update Countdown Timer

This commit is contained in:
LSvekis
2021-09-06 12:39:19 -04:00
committed by GitHub
parent 0f11d4b093
commit 4c1842233d
+6 -3
View File
@@ -1,12 +1,16 @@
const endDate = "Sept 1 2022";
update();
function update() {
const temp = countdown();
let output = "";
for (const property in temp) {
console.log(`${property}: ${temp[property]}`);
output += (`${property}: ${temp[property]} `);
}
window.setTimeout(update, 1000);
console.log(output);
setTimeout(update, 1000);
}
function countdown() {
const total = Date.parse(endDate) - new Date();
const days = Math.floor(total / (1000 * 60 * 60 * 24));
@@ -14,7 +18,6 @@ const endDate = "Sept 1 2022";
const mins = Math.floor((total / 1000 / 60) % 60);
const secs = Math.floor((total / 1000) % 60);
return {
total,
days,
hrs,
mins,