<div id="time"></div>
<script>
function showCounter(distance) {
if (i < 0) {
return;
}
var minutes = Math.floor((distance % (60 * 60)) / 60);
var seconds = Math.floor((distance % 60));
var div = document.getElementById('time');
div.innerHTML = minutes + ':' + seconds;
}
var distance = 300; // 5 minute
var i = 0;
setInterval(function () {
showCounter(300 - i);
i++;
}, 1000);
</script>