WordPress Timeago Plugin: Twitter Like Fuzzy Dates in WordPress

With web 2.0, it has become common to have fuzzy date/time (e.g. “3 minutes ago”, “10 days ago”). Twitter, Facebook, Gmail, you name it — all the big guns are following the trend.

Bloggers using WordPress should also be following this trend, just like all other social media. WordPress, by default, doesn’t have fuzzy dates support. So, I have created a plugin that uses the popular timeago jQuery plugin to create automatically updating fuzzy date/time.

Why?

  • The fuzzy date/time updates live while you are on the page, without requiring page reload.
  • It makes your site appear more lively and user friendly.
  • timeago uses microformats.
  • Fuzzy date is applied to the comments automatically, even if the default wordpress comments loop is being used. No painful rewriting required.
  • Shows time relative to user’s timezone. Normally, the date/time displayed by wordpress is based on the timezone set in wordpress configurations.

Installation:

  1. Download and extract the zip archive.
  2. Upload the plugin.
  3. Activate the plugin from Admin CP.
  4. Ensure it works (more below).

Make it work!

By default, the plugin automatically converts your date and times into fuzzy equivalent. However, it’s not perfect and may not work or appear out of context on many themes.

In that case, you will have to edit your theme templates (index.php, single.php, etc.) and replace the default the_time() / the_date() template tags with the_time_ago() (provided by the plugin).

Usage: (while in the loop or comments loop)

<?php the_time_ago(); ?>

When you need to define a custom format (displayed on mouse-over), use as following:

<?php the_time_ago('d M, Y'); ?>

Translation

Edit the file jquery.timeago.js and locate the section where it says “Translate here”. You can either modify it manually or use one of the many translations available at timeago’s repository.

Keep In Touch

Leave your suggestions and comments below, and don’t forget to subscribe to our RSS Feed and follow us on Twitter to stay updated.

20 Comments
  1. Asad, thank you for this :)
    Have to agree with you, little details like this fuzzy time makes a blog more live & human reader friendly.

  2. Hello,

    Don’t know if you follow the support forums, so I’m posting a link here:

    http://wordpress.org/support/topic/378337

  3. Hi!

    Sorry but i found bug?

    I have problem…

    http://hpguru.net/blogini-on-nyt-yhteiso/#comments

    Just say to you great plugin and i want use this but…

    I don’t see first comment sender name. Ok, second and name is gone. Why?

    How i fix it?

    • It appears you’re using a custom comments loop. Edit wp-content/plugins/timeago/timeago.js, find and remove:

      $('.comment-meta a:first').each(function() {
      var timeago = $(this).children('.timeago');
      if (timeago) {
      $(this).html(timeago);
      }
      });

  4. And good blog i add this blog rss to my rss reader.

  5. And now it’s work! Thank you for this tip. :)

    Like your plugin!

  6. Any thoughts on making this work on the auto updates from the p2 theme. I can’t figure out how to make it work with the ajax updates. Works great on normal page loads by editing the entry.php file with the_time_ago(). Started a thread on the plugin page.

    • If the theme modifications rely on AJAX requests to add data, try something like this at bottom of jquery.timeago.js file:

      $(document).ajaxStop(function() {
      	setTimeout(function() { $("abbr.timeago").timeago(); }, 20);
      });
      

      You need to call $(“abbr.timeago”).timeago(); every time you append new content to the DOM.

  7. Hello,

    im using your plugin and its excellent. But – in archive pages it didnt work quite well, because its showing “Archive for 16 day ago” instead of “Archive of April”. Its somehow possible to fix it?

    Thanks!

    • Just found another bug. In theme Therapy from WooThemes the plugin hide comment author’s name and shows only “5 minutes ago” – no name.

    • @jp: Due to custom comment loops being used, use the solution I suggested to Jyri.

      Thanks for pointing out the archives issue. Currently, the fix is to edit your archive.php file of the theme and use echo get_the_time(…); instead of the_time(…) in “Archive for …” text.

      For example:

      <h2 class="pagetitle">Archive for <?php echo get_the_time('F, Y'); ?></h2>

  8. On one of my pages it will say the time and then spits out “GMT -4″ next to all times. Any thoughts?

  9. Thanks for the response above but it did not seem to make a difference for the new posts in the P2 them which I think get pulled in from http://svn.automattic.com/wpcom-themes/p2/inc/ajax.php but I’m not all that sure. I would love to use your plugin so if you have any other suggestions I would certainly try them.

    Thanks again.

  10. Sorry i’m back but i would ask you one question… :D

    I now notified that your plugin works in wp admin area. Now i have in admin panel for example: Commentname X posted 3 minutes ago @ 3 minutes ago.

    Before: Commentname X posted 03.07.2010 @ 22:45.

    How i disable your plugin from admin panel?

    Thank you.

    Andd sorry for my bad English…

  1. Timeago Plugin
  2. Featured Plugin: Timeago – Twitter Like Fuzzy Dates in you WordPress blog | The Four-eyed Journal
  3. links for 2010-04-03 « newdisco
  4. Wordpress:Sosyal Ağlardaki Gibi Zaman Gösterimi
Leave a Reply