Human-readable Relative Time Plugin For jQuery - Livetime

Human-readable Relative Time Plugin For jQuery - Livetime
File Size: 5.01 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A minimalist jQuery data/time format plugin which turns ISO 8601 date strings into human-readable timestamps relative to your local time, such as "Just Now", "30 seconds ago", "5 minutes ago", "Yesterday", "Last month", "2 years ago", and so on.

How to use it:

1. Add jQuery JavaScript library and the jQuery livetime plugin to your html pages as usual.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="livetime.min.js"></script>

2. Create a time tag and add the machine-readable date / time using datetime attribute.

<time class="demo" datetime="1900-09-24T14:20:00.000Z"></time>
<time class="demo" datetime="2015-10-31"></time>
<time class="demo" datetime="2015-10-31T20:00"></time>
<time class="demo" datetime="2015-10-31T20:00:00"></time>
<time class="demo" datetime="2015-10-31T20:00:00.000"></time>
<time class="demo" datetime="10/31/2015 8:00 am"></time>
<time class="demo" datetime="12/25/2015 20:00:00"></time>

3. Call the function on the time tag and we're done.

$('.demo').livetime();

4. Default plugin settings.

$('.demo').livetime({
  justnow: true,
  maxtick: 86400
});

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