-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (37 loc) · 966 Bytes
/
Copy pathindex.js
File metadata and controls
46 lines (37 loc) · 966 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
35
36
37
38
39
40
41
42
43
44
45
46
const hours = document.querySelector(".hours");
const minutes = document.querySelector(".minutes");
const seconds = document.querySelector(".seconds");
const ampm = document.querySelector(".ampm")
let count=0
function digitalClock() {
let clock = new Date();
let h = clock.getHours();
let m = clock.getMinutes();
let s = clock.getSeconds();
let pm = "AM"
if (h >= 12){
pm = "PM"
}
if (s > 10){
seconds.innerHTML = s;
}else {
seconds.innerHTML =`0${s}`;
};
if (m > 10){
minutes.innerHTML = m;
}else {
minutes.innerHTML =`0${m}`;
};
if(h > 12){
h = h-12;
h = `0${h}`
}
if (h >= 10){
hours.innerHTML = h;
}else {
hours.innerHTML =`0${h}`;
};
console.log("Hello There " + count++ , h, m , s);
ampm.innerHTML = pm;
};
setInterval( () => {digitalClock()},1000);