🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@ljharb/now

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ljharb/now

The current time in milliseconds, from the most precise monotonic clock available (`performance.now` → `process.hrtime` → `Date.now` → `new Date().getTime()`), for measuring elapsed time.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
139K
56.72%
Maintainers
1
Weekly downloads
 
Created
Source

@ljharb/now Version Badge

github actions coverage License Downloads

npm badge

The current time, in milliseconds, from the most precise monotonic clock available - performance.now(), then process.hrtime(), then Date.now(), then new Date().getTime() (for ES3). Works in browsers and node, all the way back to ES3.

The returned value has an arbitrary origin and is only meaningful relative to another call: subtract two readings to get an elapsed duration, in milliseconds. Where the platform provides a monotonic clock (the first two tiers), it is unaffected by system clock changes.

Usage / Example

var now = require('@ljharb/now');
var assert = require('assert');

assert.equal(typeof now(), 'number');

var start = now();
// ... do some work ...
var elapsed = now() - start;

assert.equal(typeof elapsed, 'number');
assert.ok(elapsed >= 0);

Keywords

now

FAQs

Package last updated on 09 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts