Skip to main content

What is the relative date? The relative date is a timestamp for your post that displays when a post has been posted. WordPress helps you keep track of all the posts that you posted online on your blog or site using Display relative dates. If you are not aware of how to place a timestamp on your WordPress post then this article gives you a clear idea of how to place and display relative dates in WordPress.

2 Ways to Add Display Relative Dates

  • Using Plugin
  • Using Code

Add Relative Dates in WordPress using Plugin

[1] From your WordPress dashboard, choose Plugins.

[2] Click on Add New.

Display Relative Dates in WordPress
[3] Search and install the Meks Time Ago plugin from WordPress.

activate plugin
[4] Once installed, activate the plugin by clicking on Activate.

[5] Get back to settings and choose Dashboard.

[6] Scroll down to Meks Time Ago Options.

[7] Now you can set relative dates on your WordPress post.

Display Relative Dates in WordPress

Once the plugin is added, you can set the following

  • Apply “time ago” format to – Here you can check either the Time/Date box or even both to display on your post.
  • Apply to posts not older than – The option allows you to apply this only for the post you have chosen.
  • Place “ago” word – This allows you to set the timing for the ‘ago’ word to your post. Also, you can change the word Ago to anything like Since, From, Gone by, etc.

Also read how to Add / Embed Google Calendar in WordPress

Set Relative Dates using Code

[1] Go to the Plugin dashboard and Add a new plugin named WP-RelativeDate.

[2] Activate the Plugin and go to the Admin panel.

activate
[3] Choose Appearance and Editor from the left panel.

Editor
[4] Now you need to find the Code that looks like this

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

Most probably it is found inside the following files in the template section: content.php, comments.php, content-page.php, or content-single.php.

Display Relative Dates in WordPress
[5] Once the code is identified, replace them with <?php relative_post_the_date(); ?>.

[6] This will display the relative date on your WordPress.

See how to Add Pagination on a WordPress Site (Text and Numeric)

Using the code might be a time-consuming one and we prefer you use this method and save your time on adding the relative dates. Also, not adding a plugin could help your site be light and fast. Or if you are a newbie, you can definitely go with the plugin and there is nothing to worry about it. Do leave your experience in the comments section below. For more WordPress guides and articles, visit our blog.

Leave a Reply