Update Countdown Timer
This commit is contained in:
@@ -1,23 +1,26 @@
|
|||||||
const endDate = "Sept 1 2022";
|
const endDate = "Sept 1 2022";
|
||||||
update();
|
update();
|
||||||
function update() {
|
|
||||||
|
function update() {
|
||||||
const temp = countdown();
|
const temp = countdown();
|
||||||
|
let output = "";
|
||||||
for (const property in temp) {
|
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() {
|
}
|
||||||
|
|
||||||
|
function countdown() {
|
||||||
const total = Date.parse(endDate) - new Date();
|
const total = Date.parse(endDate) - new Date();
|
||||||
const days = Math.floor(total / (1000 * 60 * 60 * 24));
|
const days = Math.floor(total / (1000 * 60 * 60 * 24));
|
||||||
const hrs = Math.floor((total / (1000 * 60 * 60)) % 24);
|
const hrs = Math.floor((total / (1000 * 60 * 60)) % 24);
|
||||||
const mins = Math.floor((total / 1000 / 60) % 60);
|
const mins = Math.floor((total / 1000 / 60) % 60);
|
||||||
const secs = Math.floor((total / 1000) % 60);
|
const secs = Math.floor((total / 1000) % 60);
|
||||||
return {
|
return {
|
||||||
total,
|
|
||||||
days,
|
days,
|
||||||
hrs,
|
hrs,
|
||||||
mins,
|
mins,
|
||||||
secs
|
secs
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user