Skip to content

Dchole/format-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 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

About

Format time or date to show how long it has been since data was created. Ex. `2 minutes ago` or `few months ago`

Resources

Stars

Watchers

Forks

Packages

No packages published