JSFiddle - React, Tailwind, and code Playground
HTML
<span id="countdown_time"></span>
JavaScript
var
diff = 3850000;
function updateETime() {
function pad(num) {
return num > 9 ? num : '0'+num;
};
days = Math.floor( diff / (1000*60*60*24) ),
hours = Math.floor( diff / (1000*60*60) ),
mins = Math.floor( diff / (1000*60) ),
secs = Math.floor( diff / 1000 ),
dd = days,
hh = hours - days * 24,
mm = mins - hours * 60,
ss = secs - mins * 60;
document.getElementById("countdown_time")
.innerHTML =
dd + ' days ' +
pad(hh) + ':' + //' hours ' +
pad(mm) + ':' + //' minutes ' +
pad(ss) ; //+ ' seconds' ;
diff -= 1000;
}
setInterval(updateETime, 1000 );