DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Want to display human readable dates on your blog, such as “Posted 6 days ago?” There’s a lot of available functions to do so, but only a few people know that WordPress have its own built-in function to do that.

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.

Tags

Leave a Comment

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