time-age
v1.1.0
Published
Format time and date to show how long it has been since data was created. Ex. "2 minutes ago" or "3 months ago."
Downloads
6
Maintainers
Readme
🚀 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