rf-web/_includes/common/clock.html
2020-09-05 16:12:50 +02:00

19 lines
467 B
HTML

<div class="inline-block" id="clock"><p></p></div>
<script src="https://unpkg.com/spacetime"></script>
<script>
const clock = document.querySelector('#clock p');
const getTime = () => {
var d = spacetime(new Date(), 'Europe/Zurich')
return d.format('{hour-24-pad}:{minute-pad}:{second-pad}')
}
const setTime = () => {
clock.innerHTML = `<span class="time">${getTime()}</span> (CEST)`
}
setTime();
setInterval(setTime, 1000);
</script>