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.
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 :
[…] Add Fuzzy Timestamps To Your Blog […]
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!
Only one problem, on line 4 change the “<?" to "<?php". On some servers, it will crush the whole site. Regards!
ups! I mean line 41
What’s up friends, good piece of writing and fastidious arguments commented here, I am actually enjoying by these.
my blog – do kuchni