I have made a Javascript clock, when the seconds and minutes hits 60 it will count over 60 and keeps going...
function increment(){
if(running == 1){
setTimeout(function(){
Dtime++;
var hours = Math.floor(Dtime / 10 / 3600);
if(hours <= 9){
hours = "0" + hours;
}
var mins = Math.floor(Dtime / 10 / 60);
if(mins <= 9){
mins = "0" + mins;
}
var secs = Math.floor(Dtime / 10);
if(secs <= 9){
secs = "0" + secs;
}
document.getElementById("outputt").innerHTML = hours + ":" + mins + ":" + secs;
increment();
}, 100);
}
}
var Dtime=0;
var running = 1;
increment();
<div id="outputt" class="timerClock" value="00:00:00">00:00:00</div>
Basically the clock counts past 60 for minutes and seconds, I would like this to reset to 0 instead of hitting 60. I have not had the time to test hours although I'm sure it would go past 24 as well.
Please can someone explain how this would be done? I am certain its very simple but I have managed to struggle with it for a bit too long and am getting frustrated.