• I was recently working on a project where the client wanted “time ago” date stamps, such as Posted 23 minutes ago or Posted 1 week ago. For that project, we used the very nice jQuery Timeago script which automatically formats any date/time in a properly formatted tag to a timeago, kind of like this:

    [html]<abbr title="July 17, 2008"><em><abbr title="time ago">2 years ago</abbr></em></abbr>[/html]

    However, WordPress has a built-in function that will do the same thing: human_time_diff().  If you paste this code snippet into the loop, you’ll get a timeago date.

    [php]Posted <?php echo human_time_diff(get_the_time(‘U’), current_time(‘timestamp’)) . ‘ ago’; ?>[/php]

    This entry was posted on Tuesday, September 28th, 2010 at 11:36 am and is filed under WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 0 Comments

    Take a look at some of the responses we have had to this article.

  • Leave a Reply

    Let us know what you thought.

  • Name(required):

    Email(required):

    Website:

    Message: