-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (26 loc) · 695 Bytes
/
app.js
File metadata and controls
31 lines (26 loc) · 695 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
//function
function showTime() {
//variables
let date = new Date();
let h = date.getHours();
let m = date.getMinutes();
let s = date.getSeconds();
let session = "AM";
//Conditional Statement
if(h===0){
h = 12;
}
if(h > 12){
h = h-12;
session = "PM";
}
h = (h<10) ? "0" + h:h;
m = (m<10) ? "0" + m:m;
s = (s<10) ? "0" + s:s;
let time = h + " " + ":" + " " + m + " " + " : " + s + " " + session;
//selectors
document.getElementById("clockDisplay").innerText = time;
document.getElementById("clockDisplay").textContent = time;
setTimeout(showTime, 1000);
}
showTime();