Skip to content

Instantly share code, notes, and snippets.

@debianmaster
Last active October 31, 2021 06:25
Show Gist options
  • Save debianmaster/3507f499931917435e6fb5960687f392 to your computer and use it in GitHub Desktop.
Save debianmaster/3507f499931917435e6fb5960687f392 to your computer and use it in GitHub Desktop.
var seconds = 0;
var mins = 0 ;
var hours =0
const lengthOfTime=3;
function updateTimer() {
seconds = seconds+1;
if(seconds>=lengthOfTime){
seconds=0;
mins = mins+1;
if(mins>=lengthOfTime){
hours = hours+1;
mins=0;
if(hours>=24){
hours = 0;
mins=0;
seconds=0;
}
}
}
document.getElementById("seconds").innerHTML=seconds;
document.getElementById("minutes").innerHTML=mins;
document.getElementById("hours").innerHTML=hours;
}
setInterval(updateTimer,1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment