-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (69 loc) · 2.39 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meeting Raj Countdown</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #282c34;
color: white;
text-align: center;
}
#countdown {
font-size: 3rem;
}
#inputContainer {
margin-bottom: 20px;
}
input[type="datetime-local"] {
font-size: 1rem;
padding: 10px;
}
button {
font-size: 1rem;
padding: 10px 20px;
margin-top: 10px;
}
</style>
</head>
<body>
<div>
<h1>Meeting Raj Countdown</h1>
<div id="inputContainer">
<label for="datetime">Set Date and Time:</label>
<input type="datetime-local" id="datetime">
<button onclick="startCountdown()">Start Countdown</button>
</div>
<div id="countdown">00:00:00</div>
</div>
<script>
let countdownInterval;
function startCountdown() {
clearInterval(countdownInterval);
const targetDate = new Date(document.getElementById('datetime').value).getTime();
countdownInterval = setInterval(function() {
const now = new Date().getTime();
const distance = targetDate - now;
if (distance < 0) {
clearInterval(countdownInterval);
document.getElementById('countdown').innerHTML = "Time's up!";
return;
}
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById('countdown').innerHTML =
`${days}d ${hours.toString().padStart(2, '0')}h : ${minutes.toString().padStart(2, '0')}m : ${seconds.toString().padStart(2, '0')}s`;
}, 1000);
}
</script>
</body>
</html>