How To Show Relative Post Date For Your Blog Posts?

show relative post date

In most of the WordPress themes, you will notice that the published date will be showing below the post title or anywhere nearby.

There are many people who edit the theme files to show last updated date. But now another concept has come to the field.

There are a few websites which show relative post date. It means that you will see the time span which has crossed after publishing the post.

Like “2 hours ago, 18 hours ago” and similar to that. Would you like to show relative post date for all the blog posts of your blog?

Let Me Provide you The Guide To Show Relative Post Date.

As you know that the WordPress theme file structure consists many files and folders. And the output of your post is handled by the single.php file.

Though it may vary because nowadays, developers are using some similar files to control the output of the single posts.

Do you know how to edit the theme files? Well, you must learn that.

You will find any of the PHP code related to the dates. It may be different from your one theme to another.

Search for.

<?php get_the_date(); ?><?php the_date(); ?>

<?php get_the_time(); ?>

If you want to change the date of the blog posts showing on the blogpage then you have to edit the index.php.

If you are having a custom home page then another file is there which should be edited. Search for front-page.php file in your theme folder.

Replace the code with a new code.

<?php relative_post_the_date(); ?>

It would depend on your choice. If you only want to show relative post date for the single posts then edit the single.php file otherwise, search for all the files mentioned above.

How To Display relative post date Without Coding?

There are many people who are afraid of the codes. Well, there is a solution for them. They can use the plugin “WP-RelativeDate“.

Just install it and you will get a few options to configure. Set it according to our requirements. WordPress repository is full of plugins and you can find the solution for every problem.

This plugin can help you to accomplish the task of showing the post dates like you want.

Isn’t That So Easy To Configure And Show Relative Post Date?

There are a few themes which consist the relative date code inbuilt. But not every WordPress user wants that. So it’s better to do it yourself.

A good developer never adds something which isn’t relevant for all of the users. As you all know WordPress provides the freedom to its users to alter all the settings.

You can change the date display type. You can show the published date, last updated date, relative date. Add the code according to your choice. If you still have any doubt, feel free to clear it.

by Ravi Chahar

A WordPress Professional and the LinkedIn Influencer. A coder by passion and a blogger by choice. WordPress theme development is his forte. He is your WordPress guy who will teach you how to solve WordPress errors, WordPress security issues, design issues and what not.

Get Free Updates Into Your Inbox

Learn Everything Just Like I Did



  1. Wow,Ravi.

    As always, making managing our WordPress blogs easy.

    I’m on it trying this for myself. But the plugin is much easier.

    Thanks to you, bro. for sharing


    1. Hey Francis,

      Most of the people go for the plugin. But why would you increase one plugin in the list if you can do that without it?
      Just one line of the code and you would be ready to go.
      Thanks for stopping by.

Leave a Reply

Your email address will not be published. Required fields are marked *