Package Exports
- @yaireo/relative-time
- @yaireo/relative-time/relative-time.min.js
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 (@yaireo/relative-time) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Transform timestamp or date to local relative-time
Super lightweight (< 500 bytes) 🕙 Uses native browser API
Install:
NPM / CDN / Download from this repo
npm i @yaireo/relative-time -SUsage:
Import:
import RelativeTime from '@yaireo/relative-time'
And use:
```js
const relativeTime = new RelativeTime(); // defaults to OS locale
const relativeTimeSpanish = new RelativeTime({ locale: 'es' }); // set Spanish locale
console.log( relativeTime.from(new Date('2015')) ) // "6 years ago"
console.log( relativeTimeSpanish.from(new Date('2015')) ) // "hace 6 años"