How to Display Relative Dates in WordPress
Displaying Relative dates is a thing that you often see in Social Media sites like Digg where it says submitted 23 mins ago. A similar concept can be used for Blog posts and comments in WordPress where you can display relative dates as timestamps. This is a good plugin to use in the comments because it helps interaction and shows activity within the blog.
Example of Post/Comment Date and Time
Today
Yesterday
10th January 2007 (2 days ago)
25th January 2007 (2 weeks ago)
21:10 (2 seconds ago)
21:15 (5 minutes ago)
22:15 (2 hours ago)
Installation
Find a similar code in your single.php, index.php, comments.php and page.php
<?php the_date(); ?>
Replace it with:
<?php relative_post_the_date(); ?>
Note: You do not have to update all those files, only update the ones that you like, but those are some that might be needed.
Download WP Relative Date Plugin
Comments
4 Responses to “How to Display Relative Dates in WordPress”Share Your Opinions
Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!
Please make sure that you have read our Comment Policy.










Hey … thats cool stuff. thx for sharing this tip. i’ll try this on my christmas blog.
Thanks for sharing.
[Link Removed due to Violation of our Comment Policy]
Pretty good feature. Although I might not use it on my current blog, but still might be perfect for some.
Great post. I’m using it at the moment to configure the relative post dates in my blog.
I do recommend using a better implementation to avoid nasty errors should the plugin be deactivated or break. I have used something like the following:
This means that if WordPress can’t find the function then it just displays the date / time as it would normally.