time-age
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

🚀 Time age

A time formatting function to show how long it has been since inputted time

How to use

To install, run

yarn add time-age

or

npm install time-age

The function takes a single parameter of type number | string | Date

import timeAge from "time-age"

/* String type example */
timeAge(new Date()) // Just now
timeAge("2021-07-20T22:55:08.109+00:00") // 13 hours ago
/* Number type example */
timeAge(Date.now()) // Just now
timeAge(Date.now()-4000) // 4 seconds ago
const timeAge = require('time-age').default

/* String type example */
timeAge(new Date()) // Just now
timeAge("2021-07-20T22:55:08.109+00:00") // 13 hours ago
/* Number type example */
timeAge(Date.now()) // Just now
timeAge(Date.now()-4000) // 4 seconds ago

Package Sidebar

Install

npm i time-age

Weekly Downloads

7

Version

1.1.0

License

MIT

Unpacked Size

3.32 kB

Total Files

4

Last publish

Collaborators

  • dchole