# gps-time

> Small utility to convert times between GPS epoch (midnight January 6, 1980) and Unix epoch (midnight January 1, 1970), taking into account leap seconds.

Latest version **1.1.1** (published 2026-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install gps-time
pnpm add gps-time
yarn add gps-time
bun add gps-time
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-07-21 |
| First published | 2016-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | David Calhoun |
| Maintainers | davidcalhoun |
| Keywords | gps, unix, time, epoch, 1980, 1970 |

## Links

- npm: https://www.npmjs.com/package/gps-time
- Repository: https://github.com/davidcalhoun/gps-time.js
- Issues: https://github.com/davidcalhoun/gps-time.js/issues
- npm.io page: https://npm.io/package/gps-time

## 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.1 (latest) — 2026-07-21
- 1.1.0 — 2026-03-04
- 1.0.9 — 2022-11-12
- 1.0.8 — 2021-07-10
- 1.0.7 — 2020-09-12
- 1.0.6 — 2020-07-19
- 1.0.5 — 2020-04-01
- 1.0.4 — 2020-01-03
- 1.0.3 — 2016-08-06
- 1.0.2 — 2016-08-06
- 1.0.1 — 2016-01-31
- 1.0.0 — 2016-01-31

## README

# gps-time.js
[![Build Status](https://travis-ci.org/davidcalhoun/gps-time.js.svg?branch=master)](https://travis-ci.org/davidcalhoun/gps-time.js)
[![Downloads][downloads-image]][npm-url]

Small utility to convert times between GPS epoch (midnight January 6, 1980) and Unix epoch (midnight January 1, 1970), taking into account leap seconds.

It's not such a trivial matter as adding a constant number of leap seconds to all time inputs!  For any two times, a different number of leap seconds may have elapsed between them.  This utility helps figure out exactly how many have elapsed.

No dependencies!  Very small: 464 bytes gzipped.

Works on the client and on the server (in Node.js).

# Node.js installation
```javascript
npm i --save gps-time
```

# Usage
AMD and CommonJS are supported, with a fallback that defines this utility at window.gpsTime

In Node, you can bring in this utility with this:

```javascript
var gpsTime = require('gps-time');
```


## Converting from Unix time to GPS time.
```javascript
var unixMS = Date.now();  // 1454168480000
gpsTime.toGPSMS(unixMS);  // 1138203697000
```

## Converting from GPS time to Unix time.
```javascript
var gpsMS = 1138203697000;
gpsTime.toUnixMS(gpsMS);  // 1454168480000
```


# Tests
This comes with a small test suite which can be run like this:

```
$ npm install --dev
$ npm test
```

# License
[Licenced under MIT](https://github.com/davidcalhoun/gps-time.js/blob/master/LICENSE)


[downloads-image]: https://img.shields.io/npm/dm/gps-time.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/gps-time

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