Approximate (fast) current UNIX time.

Usage no npm install needed!

<script type="module">
  import approximateNow from '';



Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Approximate (fast) current UNIX time.


Sometimes you don't care about the exact time the event took place, but rather need to know approximately when. If your use case is performance sensitive, then might not be the best option because it has a measurable impact to the performance. approximate-now provides an approximate (to the error of 50ms) time without a performance penalty of


import {
} from 'approximate-now';

// `` value is updated by reference every 50ms.

Sequence guarantee

It is guaranteed that two consequent attempts to retrieve time within the same 50ms time window will have unique values, i.e.

Assuming that the current time is 0000000000000, then:; // 0000000000000; // 0000000000001; // 0000000000002

However, if is accessed more than 50 times within the same 50ms time window, then the top-most value within that interval is returned repeatedly.; // 0000000000000; // 0000000000001; // 0000000000002

// x 50; // 0000000000050; // 0000000000050; // 0000000000050

benchmark          x 19,900,411 ops/sec ±0.59% (93 runs sampled) x 82,420,291 ops/sec ±0.83% (92 runs sampled)

Use cases

Any sort of time-sensitive operations when it is sufficient to retrieve an approximate timestamp, e.g. roarr logger uses approximate-now to record the time when a log message was produced.