Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-last-seen

It is a simple light weight JavaScript package that returns relative date/time. It returns how long ago a time/date was or how long left to get to a time/date.

¶Installation

npm install simple-last-seen --save
//or with yarn
yarn add simple-last-seen

¶Usage

import RelativeTime from "simple-last-seen";

const past = new Date("2014-01-01");
const future = new Date("2050-12-01");

const today = new Date("2023-10-22");

RelativeTime.lastSeenAgo(past, today);
//=> 11 years ago

RelativeTime.fromNow(future, today);
//=> in 30 years

today is an optional parameter in the methods, when not passed, RelativeTime picks the current date/time as today.

The methods also takes a third parameter, the text to show when today === past/futrue or is just a second from past/future.

About

A lightweight javascript package that returns how long ago the time passed in was or how long till the time

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages