Skip to content

Commit 39c7e41

Browse files
committed
time parameter can be provided as query string
1 parent 2d5b281 commit 39c7e41

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

current-time.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,23 @@
1717
</head>
1818
<body>
1919
<script>
20-
now = moment();
20+
urlParams = new URLSearchParams(window.location.search);
21+
if (urlParams.has("time") === true) {
22+
time = moment(urlParams.get("time"), moment.ISO_8601);
23+
} else {
24+
time = moment();
25+
}
2126

22-
now_brussels = moment.tz(now, "Europe/Brussels").format();
23-
now_paris = moment.tz(now, "Europe/Paris").format();
24-
now_london = moment.tz(now, "Europe/London").format();
25-
now_utc = moment.tz(now, "UTC").format();
27+
timeUTC = moment.tz(time, "UTC").format();
28+
timeLondon = moment.tz(time, "Europe/London").format();
29+
timeParis = moment.tz(time, "Europe/Paris").format();
30+
timeBrussels = moment.tz(time, "Europe/Brussels").format();
2631

2732
document.body.innerHTML =
28-
"UTC : " + now_utc + "<br>" +
29-
"Europe/London : " + now_london + "<br>" +
30-
"Europe/Paris : " + now_paris + "<br>" +
31-
"Europe/Brussels : " + now_brussels;
33+
"UTC : " + timeUTC + "<br>" +
34+
"Europe/London : " + timeLondon + "<br>" +
35+
"Europe/Paris : " + timeParis + "<br>" +
36+
"Europe/Brussels : " + timeBrussels;
3237
</script>
3338
</body>
3439
</html>

0 commit comments

Comments
 (0)