Add Fuzzy Timestamps To Your Blog

I recently stumbled upon a great jQuery plugin called “timeago” that lets you easily create fuzzy timestamps (e.g. “5 minutes ago”, “about 2 months ago”, etc). So I wrote a quickie WP plugin that you can use to add this neat feature to your blog.


Basically, with this plugin you can insert a little piece of code into your theme and get nice fuzzy timestamps for your posts/pages (see the Usage section below for details). The timestamps will even update automatically – that is, if you open a page that has a timestamp saying “Posted 1 minute ago” and wait 10 minutes without reloading the page, the timestamp will then say “Posted 11 minutes ago”. People who have JavaScript disabled will see normal, non-fuzzy timestamps instead.

Here’s a screenshot showing several example timestamps :

Fuzzy Timestamp plugin screenshots

Note : The calendar icon is not included with the plugin. The site in the screenshot is using the iNove theme which adds these cute icons to post timestamps.

Download (4 KB)

Requirements :

  • WordPress 2.9+
  • PHP 5


Once you’ve installed and activated the plugin, go to the theme editor and insert <?php do_action('fuzzy_timestamp'); ?> whereever you want to use a fuzzy timestamp. For example, to use fuzzy timestamps on single post pages, open the single.php template file and replace any the WordPress loop; i.e. you can’t use to change the comment timestamps (yet).

You can also pass a second parameter to the do_action() function to specify the datetime format for the tool-tip that shows up when you mouse over a fuzzy timestamp (people who have JavaScript disabled will also see the timestamp in this format). The parameter syntax is equivalent to that used by the the_time() template function.

For example, if your theme displays the timestamps using code like this :

<?php the_time('F jS, Y'); ?>

You can add the ”F jS, Y’ bit to the plugin’s code to use the same datetime format for the tool-tips and the no-JS fallback :

<?php do_action('fuzzy_timestamp', 'F jS, Y'); ?>

The timeago script also supports i18n/different languages, but I left that feature out to avoid over-complicating the plugin. Let me know if you’d like to see it added.

Related posts :

7 Responses to “Add Fuzzy Timestamps To Your Blog”

  1. […] Add Fuzzy Timestamps To Your Blog […]

  2. […] Fuzzy time in PHP Tags: fuzzy time, timestamp Category: Javascript Top […]

  3. Aberatiu says:

    I love your plugin. I’ve been looking for a solution for more than one week, finding only poor cooding and code already to old to work so thank you very much. Good work and regards!

  4. Aberatiu says:

    Only one problem, on line 4 change the “<?" to "<?php". On some servers, it will crush the whole site. Regards!

  5. Aberatiu says:

    ups! I mean line 41

  6. do kuchni says:

    What’s up friends, good piece of writing and fastidious arguments commented here, I am actually enjoying by these.

    my blog – do kuchni

Leave a Reply