-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (25 loc) · 670 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (25 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const hour1 = document.getElementById("hour")
const minute1 = document.getElementById("minutes")
const secs1 = document.getElementById("seconds")
const ampm1 = document.getElementById("ampm")
function clockTimer(){
let h = new Date().getHours();
let m = new Date().getMinutes();
let s = new Date().getSeconds();
let ampm = "AM"
if(h>12){
h = h-12;
ampm = "PM";
}
h = h<10 ? "0" + h : h;
m = m<10 ? "0" + m : m;
s = s<10 ? "0" + s : s;
hour1.innerText = h;
minute1.innerText = m;
secs1.innerText = s;
ampm1.innerText = ampm;
setTimeout(()=>{
clockTimer()
},1000)
}
clockTimer();