Free Wordpress Blog Setup

How to Display Relative Dates in WordPress

By Editorial Staff in Wordpress Plugins
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

What Next?

Digg it
Save This Page
Subscribe to WPBeginner
Stumble it
Free Wordpress Blog Setup

Comments

4 Responses to “How to Display Relative Dates in WordPress”
  1. Joerg says:

    Hey … thats cool stuff. thx for sharing this tip. i’ll try this on my christmas blog.

  2. Thanks for sharing.

    [Link Removed due to Violation of our Comment Policy]

  3. Indrek says:

    Pretty good feature. Although I might not use it on my current blog, but still might be perfect for some.

  4. Craig Dennis says:

    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.

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.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar