Display dates as “time ago” in WordPress 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.

zeo unic

I am founder of Inspired Magazine, PSD Mod and 92pixels. You can connect with me at Twitter, Google+ and Facebook. You can learn more about me here.

No comments so far.

Be first to leave comment below.

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

Get more stuff like this
in your inbox

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