Non capisco le tue formule... le ho riscritte
codice:
function startGrbTimer(duration, display) {
var timer = duration, hours, minutes, seconds;
setInterval(function () {
days = parseInt(timer / (24*60*60), 10);
hours = parseInt(timer % (24*60*60) / (60*60), 10);
minutes = parseInt(timer % (60*60) / 60, 10);
seconds = parseInt(timer % 60, 10);
hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = days + " day" + (days > 1 ? "s" : "") + ", " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds";
if (--timer < 0) {timer = duration;}
}, 1000);
}
t = ( (2*86400) + (1*3600) + (0*60) + 10 ) // 2 giorni + 1 ore + 0 minuti + 10 secondi
startGrbTimer(t,document.getElementById("div_timer"))