-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
35 lines (26 loc) · 947 Bytes
/
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
---
layout: default
---
<h1>How long has Player been in a hotel room?</h1>
Player has been in his hotel room for approx. <span id="time-elapsed">?</span> now.
<script>
function updateTime() {
// get total seconds between the times
var delta = Math.abs(Date.now() - new Date(1666454400 * 1000)) / 1000;
// calculate (and subtract) whole days
var days = Math.floor(delta / 86400);
delta -= days * 86400;
// calculate (and subtract) whole hours
var hours = Math.floor(delta / 3600) % 24;
delta -= hours * 3600;
// calculate (and subtract) whole minutes
var minutes = Math.floor(delta / 60) % 60;
delta -= minutes * 60;
// what's left is seconds
var seconds = Math.floor(delta % 60);
let formattedString = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} second(s)`
document.getElementById("time-elapsed").innerHTML = formattedString;
}
updateTime();
setInterval(updateTime, 1000);
</script>