Socket
Socket
Sign inDemoInstall

human-time

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    human-time

show seconds in a human-readable form


Version published
Weekly downloads
70K
increased by12.54%
Maintainers
1
Install size
6.51 kB
Created
Weekly downloads
 

Readme

Source

human

show seconds in a human-readable form

Usage

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.

Node.JS

You can install the javascript version of this with

npm install human-time

and 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"

Example (C)

compile

make

run

$ ./human 65
1 minute
$ ./human 600
10 minutes

With 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 ago

License

MIT

Keywords

FAQs

Last updated on 27 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc