# @thi.ng/timestamp

> Timestamp getter wrapping (in order of preference) `process.hrtime.bigint()`, `performance.now()` or `Date.now()`

Latest version **1.1.47** (published 2026-08-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @thi.ng/timestamp
pnpm add @thi.ng/timestamp
yarn add @thi.ng/timestamp
bun add @thi.ng/timestamp
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.47 |
| Published | 2026-08-25 |
| First published | 2024-12-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Karsten Schmidt |
| Maintainers | thi.ng |
| Keywords | benchmark, bigint, measure, millisecond, nanosecond, time, timestamp, typescript |

## Links

- npm: https://www.npmjs.com/package/@thi.ng/timestamp
- Repository: https://codeberg.org/thi.ng/umbrella
- Homepage: https://thi.ng/timestamp
- Funding: https://github.com/sponsors/postspectacular
- npm.io page: https://npm.io/package/@thi.ng/timestamp

## 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

- 1.1.47 (latest) — 2026-08-25
- 1.1.46 — 2026-07-02
- 1.1.45 — 2026-06-05
- 1.1.44 — 2026-05-23
- 1.1.43 — 2026-05-20
- 1.1.41 — 2026-05-11
- 1.1.40 — 2026-05-08
- 1.1.39 — 2026-04-26
- 1.1.38 — 2026-04-18
- 1.1.37 — 2026-04-02
- 1.1.36 — 2026-03-19
- 1.1.35 — 2026-03-07
- 1.1.34 — 2026-03-07
- 1.1.33 — 2026-02-07
- 1.1.32 — 2026-01-23
- … 29 more at https://npm.io/package/@thi.ng/timestamp/versions

## README

<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#changes-to-readme-files -->
# ![@thi.ng/timestamp](https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/banners/thing-timestamp.svg?3edda6b4)

[![npm version](https://img.shields.io/npm/v/@thi.ng/timestamp.svg)](https://www.npmjs.com/package/@thi.ng/timestamp)
![npm downloads](https://img.shields.io/npm/dm/@thi.ng/timestamp.svg)
[![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)

> [!NOTE]

> This is one of 217 standalone projects. LLM-free, human-made and
> cared for software, maintained as part of the
> [@thi.ng/umbrella](https://codeberg.org/thi.ng/umbrella/) ecosystem and
> anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring
> me](https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#donations).
> Thank you! ❤️

- [About](#about)
- [Status](#status)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [API](#api)
- [Authors](#authors)
- [License](#license)

## About

Timestamp getter wrapping (in order of preference) `process.hrtime.bigint()`, `performance.now()` or `Date.now()`.

> [!NOTE]
> The functions in this package have been extracted from
> [@thi.ng/bench](https://thi.ng/bench).

This package provides the following functions:

- [`now()`](https://docs.thi.ng/umbrella/timestamp/functions/now.html) attempts
to use high-res ES
[`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
timestamps (in Node via
[`process.hrtime.bigint()`](https://nodejs.org/dist/latest-v12.x/docs/api/process.html#process_process_hrtime_bigint)),
or falls back to `performance.now()`, or lacking that, uses `Date.now()`. In all
cases, returns a (possibly rounded) nanosec-scale timestamp, either as `bigint`
or `number`.
- [`timeDiff()`](https://docs.thi.ng/umbrella/timestamp/functions/timeDiff.html)
function can be used to compute the difference between two such timestamp and
return it as milliseconds.
- [`asMillis()`](https://docs.thi.ng/umbrella/timestamp/functions/asMillis.html)
  takes a duration (either a number or bigint) in nanosec-scale and converts it
  to a JS number in milliseconds

## Status

**STABLE** - used in production

[Search or submit any issues for this package](https://codeberg.org/thi.ng/umbrella/issues?q=%5Btimestamp%5D)

## Installation

```bash
yarn add @thi.ng/timestamp
```

ESM import:

```ts
import * as tim from "@thi.ng/timestamp";
```

Browser ESM import:

```html
<script type="module" src="https://esm.run/@thi.ng/timestamp"></script>
```

[JSDelivr documentation](https://www.jsdelivr.com/)

For Node.js REPL:

```js
const tim = await import("@thi.ng/timestamp");
```

Package sizes (brotli'd, pre-treeshake): ESM: 213 bytes

## Dependencies

None

## API

[Generated API docs](https://docs.thi.ng/umbrella/timestamp/)

TODO

## Authors

- [Karsten Schmidt](https://thi.ng)

If this project contributes to an academic publication, please cite it as:

```bibtex
@misc{thing-timestamp,
  title = "@thi.ng/timestamp",
  author = "Karsten Schmidt",
  note = "https://thi.ng/timestamp",
  year = 2018
}
```

## License

&copy; 2018 - 2026 Karsten Schmidt // Apache License 2.0

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