mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Print Milliseconds In Human-Readable Format as a Unix TIL
This commit is contained in:
24
unix/print-milliseconds-in-human-readable-format.md
Normal file
24
unix/print-milliseconds-in-human-readable-format.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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
|
||||
```
|
||||
Reference in New Issue
Block a user