Time Since is a WordPress plugin which can be used to display the time since an entry or comment was published. It can for instance be used to tell you that an entry has been published “2 days, 3 hours ago”.
The code is based, with permission of course, off of Dunstan Orchard’s code with some help from Brian Meidell.
Installation
Download, rename to timesince.php, upload to wp-content/plugins on your server and activate the plugin. If you’re unsure on how to do all of this, there’s help available.
Support
Time Since is no longer supported!
Usage
Once you have installed the plugin, you need to add the activation code to your template. If at any point you’re unsure how this should work, the K2 template comes with built-in support for the Time Since plugin.
To show the time since an entry was published, insert the following code within The Loop. Most likely you’ll want to replace any template tags already showing time and date information. The code below assumes you replace any date or time template tags already present:
Since Entry Publication:
<?php if (function_exists(‘time_since’)) {
echo time_since(abs(strtotime($post->post_date_gmt . “ GMT”)), time()) . “ ago”;
} else {
the_time(‘F jS, Y’);
} ?>
Time Since Publication of Comment:
<?php if (function_exists(‘time_since’)) {
echo time_since(abs(strtotime($comment->comment_date_gmt . “ GMT”)), time()) . “ ago”;
} else {
the_time(‘F jS, Y’);
} ?>
PS: If you’re interested in Dunstan’s Time of Day code, then it’s also out as a WordPress plugin.