Browse Source

fix negative countdown

master
lub 2 years ago
parent
commit
1c5d909576
  1. 8
      main.js

8
main.js

@ -10,10 +10,10 @@ const update_countdown = () => {
const diff = target - now;
const timeleft = {};
timeleft.days = Math.floor(diff/day);
timeleft.hours = Math.floor(diff%day/hour);
timeleft.minutes = Math.floor(diff%day%hour/minute);
timeleft.seconds = Math.floor(diff%day%hour%minute/second);
timeleft.days = Math.trunc(diff/day);
timeleft.hours = Math.trunc(diff%day/hour);
timeleft.minutes = Math.trunc(diff%day%hour/minute);
timeleft.seconds = Math.trunc(diff%day%hour%minute/second);
Object.keys(timeleft).forEach((unit) => {
// retrieve value, cast it to string and optionally pad it with a leading 0

Loading…
Cancel
Save