Skip to main content
2.0.61
Light Dark System
Compact Comfortable

Timer

<zn-timer> ZnTimer
Since 1.0 experimental

Timers show the time elapsed since a Unix timestamp, updating every second.

<zn-timer class="timer-demo"></zn-timer>

<script type="module">
  document.querySelector('.timer-demo').setAttribute('timestamp', Math.floor(Date.now() / 1000) - 95);
</script>

Set timestamp to a Unix time in seconds. The timer shows how long ago that was, such as 1m 35s, and updates every second. Longer spans round to the largest unit: 3hr 12m, then 2 Days, 1 Week and 4 Months.

Examples

Since a Fixed Time

Most often the timestamp comes from the server, such as when a conversation was last updated.

<zn-timer timestamp="1743070352"></zn-timer>