Skip to content

Commit

Permalink
Merge pull request #623 from krishiv8190/patch-1
Browse files Browse the repository at this point in the history
Create clock.js
  • Loading branch information
fineanmol authored Oct 11, 2021
2 parents 3c1417b + fa789d0 commit 744d576
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Program's_Contributed_By_Contributors/JavaScript_Programs/clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function currentTime() {
var date = new Date();
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
hour = updateTime(hour);
min = updateTime(min);
sec = updateTime(sec);

document.getElementById("clock").innerText = hour + " : " + min + " : " + sec;
var t = setTimeout(function(){ currentTime() }, 1000);
}

function updateTime(k) {
if (k < 10) {
return "0" + k;
}
else {
return k;
}
}

currentTime();

0 comments on commit 744d576

Please sign in to comment.