humanize-from-now
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

humanize-from-now

Generates momentjs like time from now string

About this project

This is a tiny function to genrate the momentjs like time-from-now string. Checkout the momentjs doc for the definitions.

Installation

npm install --save humanize-from-now

Usage

First import this module in your code:

import fromNow from 'humanize-from-now';

Then you can use it like:

const duration = fromNow(time);

the time argument could be the numeric timestamp in milliseconds, a valid js Date string or a js Date object.

you can also set a failover string when the input time is not valid:

const duration = fromNow(time, 'Invalid date');

and... That's it! Have fun!

Readme

Keywords

Package Sidebar

Install

npm i humanize-from-now

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

4.83 kB

Total Files

5

Last publish

Collaborators

  • leonchen