-
Notifications
You must be signed in to change notification settings - Fork 0
/
date_time_widget.html
59 lines (53 loc) · 1.81 KB
/
date_time_widget.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
<!DOCTYPE html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: #4e2c3c;
color: #ddd7da;
font-family: 'Bebas Neue', cursive;
/* font-size: 14vw; */
font-size: 40px;
overflow-y: hidden;
}
.center {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
line-height:8vw;
}
p {
line-height: 0;
}
</style>
</head>
<body>
<div class="center">
<p id="current-date"></p>
<p id="current-time"></p>
</div>
<script>
setInterval(function() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
document.getElementById("current-time").innerHTML = hours.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) + ":" + minutes.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false});
}, 1000);
</script>
<script>
setInterval(function() {
var currentTime = new Date();
var day = currentTime.toLocaleDateString('en-Us', {day: "numeric"});
var dayOfWeek = currentTime.toLocaleDateString('en-US', {weekday: 'short'});
var month = currentTime.toLocaleDateString('en-US', {month: 'short'})
document.getElementById("current-date").innerHTML = dayOfWeek + ", " + month + ". " + day;
}, 1000);
</script>
</body>
</html>