Package Exports
- @souravdey/time-ago
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@souravdey/time-ago) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🕒time-ago
Get the time difference with current time as string with a simple npm package.
Installation
npm install @souravdey/time-agoUsage
import getTimeAgoString from '@souravdey/time-ago';
var timeAgo = getTimeAgoString(unixtimestamp);
var timeAgoAbbreviation = getTimeAgoString(unixtimestamp,true);
console.log(timeAgo) // output eg. 21 minutes
console.log(timeAgoAbbreviation) // output eg. 21 minsparams for the function
- unixtimestamp in miliseconds eg. 1617799359000
- abbreviation as
trueorfalse. It is not a mandatory feild and default value is false. If passed true it will abbreviate the units eg. minutes to mins.
getTimeAgoString function returns a string as per the time diffrence of the current time.
x seconds/secsif the diffrence between current time and unix timestamp is within 59 secs.x minutes/minsif the diffrence between current time and unix timestamp is within 1 min to 59 mins.x hours/hrsif the diffrence between current time and unix timestamp is within 1 hr to 23 hrs.x days/dsif the diffrence between current time and unix timestamp is within 1 day to 30 days.x months/mthsif the diffrence between current time and unix timestamp is within 1 month to 11 months.x years/yrsif the diffrence between current time and unix timestamp is more than 1 year.