# relative-microtime

> Get the number of microseconds elapsed since January 1, 1970 00:00:00 UTC without fear of clock drift

Latest version **2.0.0** (published 2018-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install relative-microtime
pnpm add relative-microtime
yarn add relative-microtime
bun add relative-microtime
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-10-16 |
| First published | 2018-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Thomas Watson |
| Maintainers | watson |
| Keywords | time, timer, clock, micro, microtime, hrtime, drift, skew, unix, epoch, posix |

## Links

- npm: https://www.npmjs.com/package/relative-microtime
- Repository: https://github.com/watson/relative-microtime
- Homepage: https://github.com/watson/relative-microtime#readme
- Issues: https://github.com/watson/relative-microtime/issues
- npm.io page: https://npm.io/package/relative-microtime

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-10-16
- 1.0.0 — 2018-09-20

## README

# relative-microtime

This module returns the number of microseconds elapsed since January 1,
1970 00:00:00 UTC.

Note: The returned number of microseconds are locked relative to a
specific time and is therefore not subject to clock drift. This is
contrary to how `Date.now()` operates, whos return value (in
milliseconds) is always based on the system clock.

[![npm](https://img.shields.io/npm/v/relative-microtime.svg)](https://www.npmjs.com/package/relative-microtime)
[![build status](https://travis-ci.org/watson/relative-microtime.svg?branch=master)](https://travis-ci.org/watson/relative-microtime)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install relative-microtime --save
```

## Usage

```js
const timer = require('relative-microtime')()

const milli = Date.now()
const micro = timer()

console.log(milli) // 1537446194859
console.log(micro) // 1537446194859132
```

## Gotcha

## API

### `timer = microtime()`

Sync the microtime clock to the UTC wall clock.

Returns a `timer` function synced with the UTC time when `microtime()`
was called. Any clock drift that happens after the call to `microtime()`
will not influence the returned `timer`.

### `timer()`

Returns a `Number` representing the microseconds elapsed since the UNIX
epoch.

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/relative-microtime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
