Skip to content

Commit 89a46fe

Browse files
Merge pull request #232 from AlizaHusain006/clock-project
feat: add Clock project to Frontend/MiniProjects
2 parents 55886c6 + d02cb2f commit 89a46fe

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Digital Clock</title>
7+
<style>
8+
* {
9+
margin: 0;
10+
padding: 0;
11+
box-sizing: border-box;
12+
}
13+
14+
body {
15+
font-family: 'Arial', sans-serif;
16+
display: flex;
17+
justify-content: center;
18+
align-items: center;
19+
min-height: 100vh;
20+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
21+
}
22+
23+
.clock-container {
24+
background: rgba(255, 255, 255, 0.1);
25+
backdrop-filter: blur(10px);
26+
padding: 50px 80px;
27+
border-radius: 30px;
28+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
29+
border: 2px solid rgba(255, 255, 255, 0.2);
30+
}
31+
32+
.time {
33+
font-size: 80px;
34+
font-weight: bold;
35+
color: white;
36+
text-align: center;
37+
letter-spacing: 5px;
38+
text-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
39+
}
40+
41+
.date {
42+
font-size: 24px;
43+
color: rgba(255, 255, 255, 0.9);
44+
text-align: center;
45+
margin-top: 20px;
46+
}
47+
48+
.day {
49+
font-size: 18px;
50+
color: rgba(255, 255, 255, 0.7);
51+
text-align: center;
52+
margin-top: 10px;
53+
}
54+
</style>
55+
</head>
56+
<body>
57+
<div class="clock-container">
58+
<div class="time" id="time">00:00:00</div>
59+
<div class="date" id="date">Loading...</div>
60+
<div class="day" id="day">Loading...</div>
61+
</div>
62+
63+
<script>
64+
function updateClock() {
65+
const now = new Date();
66+
67+
let hours = now.getHours();
68+
let minutes = now.getMinutes();
69+
let seconds = now.getSeconds();
70+
71+
hours = hours < 10 ? '0' + hours : hours;
72+
minutes = minutes < 10 ? '0' + minutes : minutes;
73+
seconds = seconds < 10 ? '0' + seconds : seconds;
74+
75+
const timeString = hours + ':' + minutes + ':' + seconds;
76+
document.getElementById('time').textContent = timeString;
77+
78+
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
79+
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
80+
81+
const dayName = days[now.getDay()];
82+
const day = now.getDate();
83+
const month = months[now.getMonth()];
84+
const year = now.getFullYear();
85+
86+
const dateString = month + ' ' + day + ', ' + year;
87+
88+
document.getElementById('date').textContent = dateString;
89+
document.getElementById('day').textContent = dayName;
90+
}
91+
92+
updateClock();
93+
setInterval(updateClock, 1000);
94+
</script>
95+
</body>
96+
</html>

0 commit comments

Comments
 (0)