|
TimeAgo
jquery.timeago.js
Timeago is a jQuery plugin that makes it easy to support automatically updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). Timeago was originally built for use with Yarp.com to timestamp comments.
Basic usage
jQuery(document).ready(function() {
jQuery('abbr[class*=timeago]').timeago();
});
This will turn all abbr elements with a class of timeago and an ISO 8601 timestamp in the title: <abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr> into something like this: <abbr class="timeago" title="2008-07-17T09:24:17Z">2 months ago</abbr> which yields: 2 months ago. As time passes, the timestamps will automatically update. Input methodsYou can also use it programmatically:
jQuery.timeago(new Date()); //=> "less than a minute ago"
jQuery.timeago("2008-07-17"); //=> "2 months ago"
jQuery.timeago(jQuery("abbr#some_id")); //=> "2 months ago" // [title="2008-07-20"]
Future timestampsTo support timestamps in the future, use the allowFuture setting: jQuery.timeago.settings.allowFuture = true; |
Sign in to add a comment