File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ const loading = document.getElementById("loading");
99const nextYear = new Date ( ) . getFullYear ( ) + 1 ;
1010const newYearTime = new Date ( `January 01 ${ nextYear } 00:00:00` ) ;
1111
12+ function formatTime ( unit ) {
13+ return unit < 10 ? "0" + unit : unit ;
14+ }
15+
1216function updateCountdown ( ) {
1317 const currentTime = new Date ( ) ;
1418 const difference = newYearTime - currentTime ;
@@ -17,11 +21,9 @@ function updateCountdown() {
1721 const currentMinutes = Math . floor ( difference / 1000 / 60 ) % 60 ;
1822 const currentSeconds = Math . floor ( difference / 1000 ) % 60 ;
1923 days . innerText = currentDays ;
20- hours . innerText = currentHours < 10 ? "0" + currentHours : currentHours ;
21- minutes . innerText =
22- currentMinutes < 10 ? "0" + currentMinutes : currentMinutes ;
23- seconds . innerText =
24- currentSeconds < 10 ? "0" + currentSeconds : currentSeconds ;
24+ hours . innerText = formatTime ( currentHours ) ;
25+ minutes . innerText = formatTime ( currentMinutes ) ;
26+ seconds . innerText = formatTime ( currentSeconds ) ;
2527}
2628
2729setTimeout ( ( ) => {
You can’t perform that action at this time.
0 commit comments