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.
Here’s a screenshot showing several example timestamps :
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.
fuzzy-timestamp.zip (4 KB)
- 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).
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 :