Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Relative Dates in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
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

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)


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

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Zaheer Abbas says:

    How do i use this in my custom template ? i use it nd it show me
    Fatal error: Call to undefined function relative_post_the_date() in/home/damdaar/public_html/wp-content/themes/akita/mainpage.phpon line 41

  2. 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.

  3. Indrek says:

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

  4. Michael Guilfoyle says:

    Thanks for sharing.

    [Link Removed due to Violation of our Comment Policy]

  5. Joerg says:

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

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.