-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDIGITAL CLOCK PROGRAM JAVASCRIPT.txt
More file actions
63 lines (53 loc) · 1.44 KB
/
DIGITAL CLOCK PROGRAM JAVASCRIPT.txt
File metadata and controls
63 lines (53 loc) · 1.44 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// DIGITAL CLOCK PROGRAM
function updateClock(){
const now = new Date();
let hours = now.getHours();
const meridiem = hours >= 12 ? "PM" : "AM";
hours = hours % 12 || 12;
hours = hours.toString().padStart(2,0);
const minutes = now.getMinutes().toString().padStart(2,0);
const seconds = now.getSeconds().toString().padStart(2,0);
const timeString = `${hours}:${minutes}:${seconds}${meridiem}`;
document.getElementById("clock").textContent = timeString;
}
updateClock();
setInterval(updateClock,1000);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="clock-container">
<div id="clock">00:00:00</div>
</div>
<script src="index.js"></script>
</body>
</html>
body{
background-image: url(photos.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
margin: 0;
}
#clock-container{
display:
flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#clock{
font-family: monospace;
font-size: 6.5rem;
font-weight: bold;
text-align: center;
color: white;
background-color: hsl(0,0%,100%,0.1);
backdrop-filter: blur(5px);
}