User-Friendly Date Formatting Plugin - prettydate

File Size: 95.9 Kb
Views Total: 4673
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
User-Friendly Date Formatting Plugin - prettydate

prettydate is a jQuery plugin inspired from Twitter Timeline for creating User-Friendly date formatting (x days ago,  yesterday, just now, etc. ) for your projects.  To use this plugin, you have to add an ISO8601 date to title attribute of your links. It uses clientside date and supports auto update without modifing your codes.

Basic Usage:

1. Include jQuery Library and prettydate.js

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="jquery.prettydate.js"></script>

2. Add a link with an ISO8601 date in its title

<a title="2012-02-04T20:24:17Z">February 4th, 2012</a>

3. Call the plugin

<script>
$(function() { $("a").prettyDate(); });
</script>

4. Result

1 year ago

More Examples with advanced options

Change log:

2015-07-01

  • i18n bugfix.

2014-01-10

  • Added support for the day before yesterday, fall back to days formatting if missing

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