Dead Simple Time-ago Plugin For jQuery - Lately.js

Dead Simple Time-ago Plugin For jQuery - Lately.js
File Size: 5.05 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Lately.js is an extremely lightweight (<1kb minified) jQuery plugin that automatically prints out the passed datetime in a more human readable format like '4 Months Ago', '2 Days Ago', and so on. Supports time time tag (IE 9+) and any other inline elements.

How to use it:

1. Wrap the machine-readable datetime into html elements as this:

<time class="demo" datetime="2016-12-24T23:49:41+00:00" itemprop="datePublished" pubdate>Dec 24, 2016</time>
<a href="#" class="demo" title="2017-02-14 00:01">This is a link</a>
<a href="#" class="demo">2017-01-01 00:01</a>

2. Place jQuery library and the jQuery Lately.js plugin right before the closing body tag.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="lately.js"></script>

3. Initialize the plugin and you're done.

$.lately({
  'target': '.demo'
});

4. Override the default localization strings as per your need.

$.lately({
  'lang': {
    'second': ' Seconds',
    'minute': ' Minutes',
    'hour': ' Hours',
    'day': ' Days',
    'month': ' Months',
    'year': ' Years',
    'ago': ' Ago',
    'error': 'NaN'
  }
});

Change log:

2017-02-20

  • Fixed timezone issues.

 


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