Display dates as “time ago”, the easy way

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 6 days ago”.
Paste it anywhere within the loop, save the file, and you’re done.

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

Credits: PHP Snippets.

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

Display dates as “time ago”, the easy way

Leave a Reply

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