Minimal Time Ago Plugin For jQuery - time-ago.js

File Size: 38.2 KB
Views Total: 192
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Minimal Time Ago Plugin For jQuery - time-ago.js

Yet another jQuery time-ago plugin for automatically creating timestamps with a nice readable format. 

The plugin automatically replaces ISO 8601 date and time-related data with human-readable formats like '4 days ago' or '2 minutes ago'. It strives to be simple as well as lightweight, weighing in at about 1KB compressed.

How to use it:

1. Add your timestamp in ISO 8601 format to the datetime attribute as follows:

<time datetime="2021-12-24T12:28:00-07:00" 

2. Load the jQuery time-ago plugin in the document.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/dist/time-ago.js"></script>

3. Initialize the plugin on the time element. That's it.


4. Localize the plugin as follows.

switch (s.lang && blog) {
  // if "s.lang" is Indonesian
  case 'fr':
    now = '...';
    sec = '...';
    min = '...';
    hour = '...';
    day = ''...';
    week = '...';
    month = '...';
    year = '...';
  // the default "s.lang" is English
    now = 'just now';
    sec = 'seconds ago';
    min = 'minutes ago';
    hour = 'hours ago';
    day = 'days ago';
    week = 'weeks ago';
    month = 'months ago';
    year = 'years ago';
    lang: 'fr',

5. Determine whether to enable 'xx seconds ago'. Default: true (disable).

    jutstNow: false,

This awesome jQuery plugin is developed by xxrbm. For more Advanced Usages, please check the demo page or visit the official website.