-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (24 loc) · 711 Bytes
/
Copy pathapp.js
File metadata and controls
31 lines (24 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const endDate = "22 june 2024 00:00 pm";
document.getElementById("end-Date").innerText = endDate;
const inputs = document.querySelectorAll("input")
function clock () {
const end = new Date(endDate)
const now = new Date()
const diff = (end - now)/ 1000;
if (diff < 0) return;
// convert into Days
inputs[0].value = Math.floor(diff / 3600 / 24);
// convert into hours
inputs[1].value = Math.floor((diff / 3600) % 24);
// converts into minuts
inputs[2].value = Math.floor((diff / 60) % 60);
// converts into sec
inputs[3].value = Math.floor((diff) % 60);
}
// for calling the function of clock()
setInterval(
() =>{
clock();
},
1000
)