-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
21 lines (20 loc) · 890 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const days = document.querySelector("#days")
const hours = document.querySelector("#hours")
const minutes = document.querySelector("#mins")
const seconds = document.querySelector("#seconds")
function Updatetime() {
const currentyear = new Date().getFullYear();
const newYear = new Date(`january 1 ${currentyear + 1} 00:00:00`);
const currentDate = new Date();
const diff = newYear - currentDate;
const d = Math.floor(diff / 1000 / 60 / 60 / 24);
const h = Math.floor((diff / 1000 / 60 / 60) % 24);
const m = Math.floor((diff / 1000 / 60) % 60);
const s = Math.floor((diff / 1000) % 60);
days.innerHTML = d < 10 ? "0" + d : d;
hours.innerHTML = h < 10 ? "0" + h : h;
minutes.innerHTML = m < 10 ? "0" + m : m;
seconds.innerHTML = s < 10 ? "0" + s : s;
//console.log(d + " " + h + " " + m + " " + s + " ");
}
setInterval(Updatetime, 1000);