1.0.0 • Published 2 years ago

simple-vue3-timeago v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

simple-vue3-timeago

simple-vue3-timeago is a simple react component used to format date with *** time ago or in *** time statement. eg: '3 hours ago' or 'in 3 hours'. This is zero dependency component but it's based on timeago.js which is a simple javascript module.

  • Realtime render.
  • Efficient. When the time is 3 hour ago, the interval will update after an hour (3600 * 1000 ms).
  • Locales supported (I plan to release more locales in the future).

Install

npm install simple-vue3-timeago

or

yarn add simple-vue3-timeago

Usage

<script>
  import Vue3Timeago from 'simple-vue3-timeago';
  export default {
    ...
    components: {
      Vue3Timeago
    }
  }
</script>

<template>
  <div id="app">
    <vue3-timeago
      datetime="2022-02-20 11:32:00"
      locale="en_US" />
  </div>
</template>

Component props

Prop nameDescriptionTypeRequiredDefault
datetimeString\|Datetrue
localeStringfalse"en_US"
relativeDateThe datetime to be calculated interval relative toString\|Datefalsenull
liveUpdate the component live using the minLiveIntervalBooleanfalsefalse
minLiveIntervalThe min interval in milliseconds to update the componentNumberfalse10000

You can apply any style or CSS class to the component it will be applied to the root element.

Props not documented above are applied to the root element.

LICENSE

MIT