-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (83 loc) · 2.49 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jnpr-ps-cloud.com</title>
<style>
body {
font-family: sans-serif;
margin: 0;
padding: 0;
height: 100vh;
}
.clock {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #424558;
}
.time {
font-size: 80px;
font-weight: bold;
color: #fff;
}
.date-time {
font-size: 20px;
color: #fff;
}
@media screen and (max-width: 768px) {
.time {
font-size: 50px;
}
}
</style>
<script type="text/javascript">
window.onload = function() {
var datetime = new Date();
console.log(datetime);
document.getElementById("time").textContent = datetime.toISOString();
}
</script>
</head>
<body>
<h1>www.jnpr-ps-cloud.com</h1>
<p style="text-align:right;"> Connected: <span id="time"> </span>.</p>
<div class="clock">
<div class="time"></div>
<div class="date-time"></div>
</div>
<script>
// from https://www.tutorialstonight.com/html5-digital-clock-with-javascript
var time = document.querySelector('.time');
var dateTime = document.querySelector('.date-time');
function updateClock() {
// Get the current time, day , month and year
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var day = now.getDay();
var date = now.getDate();
var month = now.getMonth();
var year = now.getFullYear();
// store day and month name in an array
var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// format date and time
hours = hours % 12 || 12;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
date = date < 10 ? '0' + date : date;
// display date and time
var period = hours > 12 ? 'AM' : 'PM';
time.innerHTML = hours + ':' + minutes + ':' + seconds + ' ' + period;
dateTime.innerHTML = dayNames[day] + ', ' + monthNames[month] + ' ' + date + ', ' + year;
}
updateClock();
setInterval(updateClock, 1000);
</script>
</body>
</html>