Simple Flexible Relative Date/Time Plugin With jQuery - liveTimeAgo.js

File Size: 6.41 KB
Views Total: 1025
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Simple Flexible Relative Date/Time Plugin With jQuery - liveTimeAgo.js

Just another jQuery based relative time plugin used to parse human readable dates and times that supports 3 date formats: Datetime, Date and Unix Timestamp.

How to use it:

1. Load jQuery library and the jQuery liveTimeAgo.js plugin and we're ready to go.

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

2. Add the Datetime, Date or Timestamp you want to parse into DIV elements or by using data-lta-value attribute like this:

<div class="liveTime">2016-06-22 00:01:00</div>
<div class="liveTime" data-lta-value="2015-12-24"></div>
<div class="liveTime" data-lta-type="timestamp" data-lta-value="1466431440"></div>

3. Initialize the plugin and done.

$('.liveTime').liveTimeAgo();

4. Override the default output strings.

$('.liveTime').liveTimeAgo({
  translate: {
    'year': '% year ago',
    'years': '% years ago',
    'month':'% month ago',
    'months':'% months ago',
    'day': '% day ago',
    'days': '% days ago',
    'hour': '% hour ago',
    'hours': '% hours ago',
    'minute': '% minute ago',
    'minutes': '% minutes ago',
    'seconds': 'few seconds ago',
    'error': 'unknow time',
  }
});

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