Skip to content
Devix Open Source

When the visitor's clock is wrong

Drag a browser clock twenty minutes out and watch one countdown end early while the one following the server does not.

Live preview
<div class="demo demo--wide">
  <div class="pair">
    <div class="side">
      <p class="demo-hint">Trusting the visitor's clock</p>
      <div id="naive"></div>
    </div>
    <div class="side">
      <p class="demo-hint">Following the server</p>
      <div id="synced"></div>
    </div>
  </div>

  <div class="demo-row">
    <label class="demo-hint" for="skew">This browser's clock is</label>
    <input class="slider" id="skew" type="range" min="-30" max="30" step="1" value="0">
    <output class="demo-chip" id="skewOut">correct</output>
  </div>

  <dl class="demo-kv" id="out"></dl>

  <p class="demo-hint">Both count to the same instant. The left one asks this machine what time it is;
    the right one was told the server's time once, at render, and has used the offset ever since.</p>
</div>