Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Timeago is a jQuery plugin that makes it easy to support automatically updating fuzzy timestamps (e.g. "4 minutes ago").

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.markdown

Please note: changes introduced in this fork:

1) Use 'data-time' attribute instead of the 'title' attribute for storing the ISO 8601 timestamp.

2) New configuration setting to enable/disable overwriting 'title' attribute with the tag content (defaults to true)

3) New configuration setting to enable/disable 'title' localization when we detect the title will contain a UTC date (defaults to false)

4) Updates to this README to reflect the changes

You can use this rails helper method in companion with this fork.

timeago: a jQuery plugin

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") from ISO 8601 formatted dates and times embedded in your HTML (à la microformats).

Usage

First, load jQuery and the plugin:

<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>

Now, let's attach it to your timestamps on DOM ready:

<pre>
   jQuery(document).ready(function() {
     jQuery("abbr.timeago").timeago();
   });
</pre>

This will turn all abbr elements with a class of timeago and an ISO 8601 timestamp in the title:

<abbr class="timeago" data-time="2012-02-07T10:29:44Z">2012-02-07 10:29:44 UTC</abbr>

into something like this:

<abbr class="timeago" data-time="2012-02-07T10:29:44Z" title="2012-02-07 10:29:44 UTC">about an hour ago</abbr>

or, when title is disabled in settings (in case you don't want tooltips):

<abbr class="timeago" data-time="2012-02-07T10:29:44Z">about an hour ago</abbr>

or, when title and title localization are both enabled (and the system and browser language is in spanish):

<abbr class="timeago" data-time="2012-02-07T10:29:44Z" title="7 de febrero de 2012 10:29:44 GMT+00:00">about an hour ago</span>

As time passes, the timestamps will automatically update.

For more usage and examples: http://timeago.yarp.com/

For different language configurations: http://gist.github.com/6251

Author

Ryan McGeary (@rmm5t) Fork by Jesus L. / Zheileman

Other

MIT License

Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [dot] org)

Something went wrong with that request. Please try again.