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

You Might Also Like...

  • How to display Twitter-like “time ago” on your WordPress blog

    1591 readersTwitter have a really cool built-in function that display time from now, like "3 days ago" or "more than a month ago". Doing so with WordPress is not hard using some PHP. Here is a function to do so.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it

  • Display most recent comments with Gravatar

    1587 readersIs your blog popular? Do you got receive lots of comments from your readers? If yes, what about displaying the most recent comments in your blog sidebar (or elsewhere) to let your visitors knowing about the discussion?Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!Display

  • How to display an incrementing number next to each published post

    1786 readersEver wished to be able to automatically number your posts (Like Article 1, Article 2, and so on) like sites such as A List Apart are doing? If yes, just read this recipe which will show you how to do it easily.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you

  • How to display your average feed readers

    2494 readersMany bloggers are using Feedburner "chicklet" to display their subscribers count. If you want to be able to display the count for an average 7 days, here is a piece of code you're going to love.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to

  • ;)

    WordPress tip : How to change the dashboard footer text

    1335 readersWhen building a site for a client, it can be useful to be able to modify the dashboard footer text. This recipe is going to show you how you can easily do it using a hook.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip

  • ;)

    WordPress hack: Show your top contributors without a plugin

    2362 readersDo you ever wished to be able to list your top contributors without using a plugin? If yes, you'll be happy with this recipe that will show you how to do it. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress hack: Show your top

  • WordPress tip: Allow contributors to upload files

    1649 readersIf you have contributors to your blog, you probably got annoyed to see that they can't upload files and images while writing guest posts for you. Today's recipe will solve the problem, allowing contributors to upload files to your blog.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try

  • WordPress hack: Get popular posts by comments count

    2742 readersIn blogging, it is useful to be able to display your most popular posts. There's WordPress plugins to do that, but you don't need it: This code will display your most popular posts, accordoing to the comments count, without requiring you to use a plugin.Looking for WordPress hosting? Try WP Web Host. Prices starts at

  • WordPress hack: Get rid of HTML in comments

    831 readersHTML in comments can be a good things, but many times people abuse it, for example by inserting links. In this recipe, I'll show you how you can automatically get rid of any HTML entered in your post comments.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it

  • Add a favicon to your WordPress blog using a hook

    1375 readersNowadays, any serious blog have its own favicon. To add yours into WordPress, you can directly edit header.php or you can use a more clean technique, using the power of WordPress hooks.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!Add a favicon to your WordPress