Display Dates in “Time Ago” Format in WordPress?







Some time we need to display our publish date or time of post in different format like how much time ago you publish the post. Here is the function for solve that problem.

wordpress

To display human readable dates on your blog, you have to use the human_time_diff() function. The following piece of code will show a post date like “Posted 3 days ago”.

Paste this code  anywhere within the loop, save the file, and you’re done.

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

Share With Friends

Also Read   How to prevent mail from going to spam using php?

Speak Your Mind

*

Time limit is exhausted. Please reload CAPTCHA.