Created
March 18, 2022 07:08
-
-
Save geryxyz/6f1e75f00337af15944e53bc1365c7a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script> | |
<script src="https://momentjs.com/downloads/moment-timezone-with-data-10-year-range.js"></script> | |
<script type="text/javascript"> | |
let my_zone = moment.tz.guess(true); | |
function my(date, duration_text) { | |
let conf_date = moment.tz(date, "CET"); | |
let my_date = moment(conf_date).tz(my_zone); | |
let duration = moment.duration(duration_text); | |
return '' | |
+ `<td>${my_date.fromNow()}</td>` | |
+ `<td>${conf_date.format("llll")}</td>` | |
+ `<td>${my_date.format("llll")}</td>` | |
+ `<td>${duration.humanize()}</td>`; | |
} | |
</script> | |
<!-- How to use? --> | |
<table> | |
<thead> | |
<tr> | |
<th>Relative Time</th> | |
<th>Start in CET</th> | |
<th>Start in Your Time Zone</th> | |
<th>Duration</th> | |
<th>Program</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="highlighted"> | |
<script> | |
document.write(my("2022-03-18 15:00", "0:15")); | |
</script> | |
<td> | |
<strong class="emph">Welcome and Introduction</strong> | |
</td> | |
</tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment