JSFiddle - React, Tailwind, and code Playground
HTML
<span id="timer"></span>
JavaScript
function countdown(timestamp) {
var hours = parseInt( Math.abs( (timestamp/3600) ) );
var minutes = parseInt( Math.abs( ((timestamp%3600)/60) ) );
var seconds = parseInt( Math.abs( ((timestamp-hours*3600-minutes*60) ) ) );
if(hours<10)
hours='0'+hours.toString();
if(minutes<10)
minutes='0'+minutes.toString();
if(seconds<10)
seconds='0'+seconds.toString();
var text = hours + ':' + minutes + ':' + seconds;
document.getElementById('timer').textContent = text;
}
var sec = 410;
var timer = setInterval(function(){
countdown(sec);
sec -=1;
if (sec <= 0) clearInterval(timer);
}, 1000);