Time past is a simple package that helps compute the time that has elapsed since a particular date. It converts dates to elapsed time.
It can be headache to write all that code that computes the time that has passed since the current date, hence this package.
- Compute time elapsed from specific date till now.
- Compute time elapsed between two dates.
- Simply download the package as a development dependency with
npm i time_past
. - Import and use
import TimePast from 'time_past';
function() {
const date = '2012-10-10'
const elapsedTime = TimePast.inWords(data);
console.log(elapsedTime); // '7 years ago'
}
inWords: This method computes the elapsed time from a previous date till now. The previous date can either be a string or a Javascript Date object. Returned value will be a string.
Parameters | Type | Description | Example |
---|---|---|---|
date | Date | string |
const elapsedTime = TimePast.inWords(
'2012-10-10',
);
console.log(elapsedTime); // '7 years ago'
Jojitoon: ๐จ๐ฟProfile
Opeoluwa Iyi-Kuyoro: ๐จ๐ฟProfile - WebSite
PR Style: Please use the template you find in the PR message to compose one.