• Blog

    Latest from our Blog

  • Tools

    Our Favourite WP Tools

  • Hosting

    Recommended Web Hosts

  • Coupons

    Get great money off deals

  • Themes

    WordPress Theme Directory

  • Plugins

    WordPress Plugins Directory

  • Promote

    Your WordPress Product

If you’d rather show the times on your blog in more user-friendly way, there is a WordPress function called “Human Time Diff” that you can use.

Instead of displaying time in the usual manner of Day Month Year, it will display as “3 days ago” or “2 hours ago” etc – the same style of date that is used on Twitter and Facebook, that people have become used to.

If you’d like to display this for posts, wherever the date is displayed in your theme, replace it with this code :

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

If you’d like to do this for comments, the code is :

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

There you have it, a simple way to change up your theme a bit.


Post Tags

Author:

Oliver Dale is the founder of Kooc Media, a small internet company based in the UK. Kooc Media runs several high-profile websites including WPLift, ThemeFurnace and DesignersTalk.

Leave Yours +

4 Comments

  1. Anonymous

    And what page would I be looking in to find that code?

  2. Tony

    thanks for this information, i want to know how do i setup my author box like yours my site has multiple authors and i want each others have there own social links how can i show social links in author box, and recent post from authors is there an tutorial u have or suggestion thanks very much

  3. Wow this works perfectely. Is there any way to have time ago display Using Ajax so that we not need to refresh page each time and this shows the most accurate time ago for post…

Leave a Reply

* Required Fields.
Your email will not be published.

Search

Our Sponsors