package
show seconds in a human-readable form
npm install human-timeGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
5.7 kB
Includes dependencies.
show seconds in a human-readable form
This repository comes with a couple of implementations of the base algorithm in different languages. You can use any by simply dropping the logic into your source code.
You can install the javascript version of this with
npm install human-timeand use it like
var human = require('human-time');
human(754);
// => "12 minutes ago"
human(new Date(Date.now() + 5 * 1000))
// => "5 seconds from now"
human(new Date(Date.now() - 5 * 1000))
// => "5 seconds ago"compile
makerun
$ ./human 65
1 minute
$ ./human 600
10 minutesWith the C example, you can optionally pass -s to get a suffix
$ ./human 57483
15 hours
$ ./human -s 57483
15 hours from now
$ ./human -s -57483
15 hours agoMIT