Skip to content

Commit

Permalink
Merge pull request #2180 from AvidCoder101/master
Browse files Browse the repository at this point in the history
Added a clock app
  • Loading branch information
fineanmol committed Oct 3, 2022
2 parents 7c2ce5d + cc73a9f commit 2d6f043
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions js/clock-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function time() {
const today = new Date();
let hour = today.getHours();
let min = today.getMinutes();
let sec = today.getSeconds();
min = checkTime(min);
sec = checkTime(sec);
document.getElementById('txt').innerHTML = hour + ":" + min + ":" + sec;
setTimeout(time, 1000);
}

function checkTime(x){
if (x < 10){
x = "0" + x;
}
return x;
}

0 comments on commit 2d6f043

Please sign in to comment.