Graphic Design / Photography Inspiration Blog

Display dates as “time ago” in WordPress


Many people want to know about this function that how to change date as “time ago” or “posted 14 days ago”. WordPress has built-in function to do this.
We just need to add a line of code and your time will display as “posted 4 days ago”. For this we will use human_time_diff() function to our file.

Posted <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>

Paste it anywhere you want to display the date, click the save button and just check your date by refreshing your page.
I hope you have enjoyed this article.

Leave A Reply

Your email address will not be published.

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.