-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (64 loc) · 2.35 KB
/
index.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clock</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
</head>
<body>
<div class="digital-clock">
<div class="time">
<span class="hours">08</span>
<span class="dots">:</span>
<span class="minutes">30</span>
<div class="right-side">
<span class="period">PM</span>
<span class="seconds">20</span>
</div>
</div>
<div class="calender">
<span class="month-name">Mar</span>,
<span class="day-name">Sunday</span>
<span class="day-number">6</span>
<span class="year">2022</span>
</div>
</div>
<script>
function clock() {
var today = new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
let period = "AM";
if (hours >= 12) {
period = "PM";
}
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
document.querySelector(".hours").innerHTML = hours;
document.querySelector(".minutes").innerHTML = minutes;
document.querySelector(".period").innerHTML = period;
document.querySelector(".seconds").innerHTML = seconds;
}
var updateClock = setInterval(clock, 1000);
var today = new Date();
const dayNumber = today.getDate();
const year = today.getFullYear();
const dayName = today.toLocaleString("default", { weekday: "long" });
const monthName = today.toLocaleString("default", { month: "short" });
document.querySelector(".month-name").innerHTML = monthName
document.querySelector(".day-name").innerHTML = dayName
document.querySelector(".day-number").innerHTML = dayNumber
document.querySelector(".year").innerHTML = year
</script>
</body>
</html>