Node Microtime

Get the current time in microseconds
Alternatives To Node Microtime
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Libfaketime2,2911a month ago1February 27, 201817gpl-2.0C
libfaketime modifies the system time for a single application
Elevenclock1,958
6 days ago7gpl-3.0Python
ElevenClock: Customize Windows 11 taskbar clock
Truetime Android1,316
19 days ago36apache-2.0Kotlin
Android NTP time library. Get the true current time impervious to device clock time changes
Time1,000
2 years ago76C++
Time library for Arduino
Link969
8 days ago18otherC++
Ableton Link
Fake Timers75044,9012,88313 days ago44February 04, 202021bsd-3-clauseJavaScript
Fake setTimeout and friends (collectively known as "timers"). Useful in your JavaScript tests. Extracted from Sinon.JS
Clock64613553114 days ago15November 15, 20213mitGo
Clock is a small library for mocking time in Go.
Node Microtime5654,07766410 months ago39June 09, 20221mitC++
Get the current time in microseconds
Bemanalogclock488
116 years ago7April 28, 20162mitObjective-C
iOS library to create elegant, interactive clocks.
React Datetime Picker47692412 days ago48September 19, 20226mitTypeScript
A datetime picker for your React app.
Alternatives To Node Microtime
Select To Compare


Alternative Project Comparisons
Readme

node-microtime

npm npm

Date.now() will only give you accuracy in milliseconds. This module calls gettimeofday(2) to get the time in microseconds and provides it in a few different formats. The same warning from that function applies: The resolution of the system clock is hardware dependent, and the time may be updated continuously or in ``ticks.''

N-API Support

As of version 3.0.0, this library is built using the N-API library. This should allow you to upgrade to newer versions of Node.js without having to reinstall / rebuild this library.

Version 3.0.0 and later also bundle prebuilt binaries for common systems in the npm package itself. These will be used if the version of Node you are using supports N-API (>= v6.14.2), otherwise the binary will be recompiled on install.

Installation

npm install microtime

Usage

microtime.now()

Get the current time in microseconds as an integer.

microtime.nowDouble()

Get the current time in seconds as a floating point number with microsecond accuracy (similar to time.time() in Python and Time.now.to_f in Ruby).

microtime.nowStruct()

Get the current time and return as a list with seconds and microseconds (matching the return value of gettimeofday(2)).

Example

> var microtime = require('microtime')
> microtime.now()
1297448895297028
> microtime.nowDouble()
1297448897.600976
> microtime.nowStruct()
[ 1297448902, 753875 ]

Estimating clock resolution

Starting with version 0.1.3, there is a test script that tries to guess the clock resolution. You can run it with npm test microtime. Example output:

microtime.now() = 1298960083489806
microtime.nowDouble() = 1298960083.511521
microtime.nowStruct() = [ 1298960083, 511587 ]

Guessing clock resolution...
Clock resolution observed: 1us
Popular Time Projects
Popular Clock Projects
Popular Libraries Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Plus Plus
Time
Clock