# hh-mm-ss

> Simple hh:mm:ss time formatting utility

Latest version **1.2.0** (published 2017-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install hh-mm-ss
pnpm add hh-mm-ss
yarn add hh-mm-ss
bun add hh-mm-ss
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2017-09-22 |
| First published | 2016-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/hh-mm-ss) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Adam Gotlib |
| Maintainers | goldob |
| Keywords | time format, hours, minutes, seconds, miliseconds, hh:mm:ss |

## Links

- npm: https://www.npmjs.com/package/hh-mm-ss
- Repository: https://github.com/Goldob/hh-mm-ss
- Homepage: https://github.com/Goldob/hh-mm-ss#readme
- Issues: https://github.com/Goldob/hh-mm-ss/issues
- npm.io page: https://npm.io/package/hh-mm-ss

## Dependencies (1)

- [zero-fill](https://npm.io/package/zero-fill.md) ^2.2.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2017-09-22
- 1.1.0 — 2016-08-28
- 1.0.1 — 2016-07-11
- 1.0.0 — 2016-07-09

## README

# hh-mm-ss: time formatting utility
[![Build Status](https://travis-ci.org/Goldob/hh-mm-ss.svg?branch=master)](https://travis-ci.org/Goldob/hh-mm-ss)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)


:watch: Convert seconds or miliseconds to `hh:mm:ss` format and vice versa.

```js
var TimeFormat = require('hh-mm-ss')

TimeFormat.toS('137:00:00')            // 493200
TimeFormat.toS('02:00')                // 120
TimeFormat.toS('02:00', 'hh:mm')       // 7200

TimeFormat.fromS(194)                  // '03:14'
TimeFormat.fromS(150, 'hh:mm:ss')      // '00:02:30'
TimeFormat.fromS(8100, 'hh:mm')        // '02:15'

TimeFormat.fromMs(12345)               // '00:12.345'
```

## Usage

### `toMs(time, format)`

Convert given `hh:mm:ss` formatted string to miliseconds

#### Parameters
- `time` String representation
- `format` _(optional)_ Default input format. If present, it will be used to resolve amiguities during interpretation. If not specified, `mm:ss` is implied. See section below for supported format list

### `toS(time, format)`

Convert given `hh:mm:ss` formatted string to seconds

#### Parameters
- `time` String representation
- `format` _(optional)_ Default input format. If present, it will be used to resolve amiguities during interpretation. If not specified, `mm:ss` is implied. See section below for supported format list

### `fromMs(ms, format)`

Generate formatted string from time in miliseconds

#### Parameters
- `ms` Time in miliseconds
- `format` _(optional)_ Default output format. If not specified, `mm:ss` is implied. See section below for supported format list.

### `fromS(s, format)`

Generate formatted string from time in seconds

#### Parameters
- `s` Time in seconds
- `format` _(optional)_ Default output format. If not specified, `mm:ss` is implied. See section below for supported format list

### Supported time formats
The following formats are supported: `mm:ss`, `hh:mm`, `hh:mm:ss`, `mm:ss.sss`, `hh:mm:ss.sss`.

- `hh` - hours
- `mm` - minutes
- `ss` - second
- `sss` - miliseconds

Specified format constitutes a baseline for corresponding functions, but will be appropriately extended as needed. For example, `fromMs(9000, 'mm:ss')` will return `01:30`, yet `fromMs(9500, 'mm:ss')` will return `01:30.500` to account for the miliseconds part.

## Install

`npm install hh-mm-ss --save`

## License

MIT

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