JSPM

@yaireo/relative-time

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2487
  • Score
    100M100P100Q132113F
  • License MIT

javascript function to transform timestamp or date to local relative-time

Package Exports

  • @yaireo/relative-time

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


Features:

  • Super lightweight (< 500 bytes minified)
  • Uses native browser API

Install:

Use from CDN / Download from this repo / NPM

npm i @yaireo/relative-time -S

Usage:

Import CSS file via JS

import RelativeTime from '@yaireo/relative-Time'

And use

const relativeTime = new RelativeTime(); // defaults to OS locale
const relativeTimeSpanish = new RelativeTime({ locale: 'es' }); // set locale to Spanish

console.log(   relativeTime.from(new Date('2015'))  )
console.log(   relativeTimeSpanish.from(new Date('2015'))  )