1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 15:48:01 +00:00
Files
til/unix/print-milliseconds-in-human-readable-format.md

25 lines
764 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Print Milliseconds In Human-Readable Format
I ran a command in a program. It doesn't really matter what command or program.
What does matter is that it took a long time and when it finished, it told me
how long it took, but in milliseconds.
```
835953ms
```
Typically, when I see a timing number like this, I open Alfred and do some
quick math (`N / 1000 / 60 / 60` or something like that).
There is an easier way, using the
[`pretty-ms-cli`](https://github.com/sindresorhus/pretty-ms-cli). This
purpose-built CLI can be run using something like
[`npx`](https://www.npmjs.com/package/npx). All I do is hand it the number of
milliseconds and it prints out how long that is in something that I can
understand.
```bash
npx pretty-ms-cli 835953
13m 56s
```