We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ce1f10d + 93d7011 commit 2cdafffCopy full SHA for 2cdafff
Clock/Rohan
@@ -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