Skip to content

Commit 2cdafff

Browse files
Merge pull request #1046 from RS-labhub/patch-1
Create Rohan
2 parents ce1f10d + 93d7011 commit 2cdafff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: Clock/Rohan

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<body onload="startTime()">
5+
6+
<h2>JavaScript Clock</h2>
7+
8+
<div id="txt"></div>
9+
10+
<script>
11+
function startTime() {
12+
const today = new Date();
13+
let h = today.getHours();
14+
let m = today.getMinutes();
15+
let s = today.getSeconds();
16+
m = checkTime(m);
17+
s = checkTime(s);
18+
document.getElementById('txt').innerHTML = h + ":" + m + ":" + s;
19+
setTimeout(startTime, 1000);
20+
}
21+
22+
function checkTime(i) {
23+
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
24+
return i;
25+
}
26+
</script>
27+
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)