MCPcopy Create free account
hub / github.com/codemistic/Web-Development / countdown

Function countdown

New Year CountDown App/script.js:7–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7function countdown(){
8
9var currentTime= new Date().getTime(); // Curent Time
10const newYear = new Date("dec 31, 2022 23:59:59").getTime(); // destination time
11
12var difference = newYear - currentTime;
13// you have got the answere but in milliseconds
14
15var seconds,hours,days,minutes;
16seconds = Math.floor((difference%(1000*60)/1000));
17minutes = Math.floor(difference%(1000*60*60)/(1000*60));
18hours = Math.floor((difference%(1000*60*60*24))/(1000*60*60));
19days = Math.floor(difference/(1000*60*60*24));
20
21daysEl.innerHTML = days;
22 hourEl.innerHTML =Timeformat(hours);
23minEl.innerHTML = Timeformat(minutes);
24secEl.innerHTML = Timeformat(seconds);
25
26};
27
28function Timeformat (time) {
29 if(time < 10)

Callers

nothing calls this directly

Calls 1

TimeformatFunction · 0.85

Tested by

no test coverage detected