We have talked about relative dates and showed you a function WordPress already had prepared for use. By using the function, you can easily show that specific post was published a few seconds, hours, days or weeks before.
While the function is really cool and allows you to use it anywhere on your site, we haven’t mentioned how to do the same for the comments. Instead of another function, we’re about to show you a plugin which will allow you to add relative dates both to your posts and comments. Yes, this plugin can be used to replace the function from the previously mentioned article as well.
By using WP-RelativeDate, you avoid using the function from the previous article and add the same functionality to your comments. Sounds cool, right? If your answer is yes, this all you have to do.
- Navigate to Plugins -> Add New
- Search for “WP-RelativeDate” plugin
- Install and activate it
Another cool part of the plugin is that you won’t have to set up a thing. The moment after the plugin is activated, your posts and comments will be updated with the new timestamp. In the following lines you can see few examples:
Post/Comment Date examples:
- Today, Yesterday, 17th February 2016 5 days ago)
- 8th January 2016 (2 weeks ago)
Post/Comment Time examples:
- 19:10 (2 seconds ago)
- 11:15 (7 minutes ago)
- 23:10 (4 hours ago)
Still, if automatically showing the new timestamp isn’t enough for you, you can show one by yourself. Yes, there is shortcode you can use in your post to show a timestamp wherever you place that shortcode. For example:
[relativedate date_format=”jS F Y” ago_only=”false”]
[relativetime time_format=”H:i” ago_only=”false”]