How Long Ago?

Today I added a new function to display how long ago a post was posted to the site. So, more or less this post is just testing that new functionality.

If anyone is interested in adding this functionality to there own WordPress powered site, just add the following code to your function.php in your theme:

add_filter('the_time', 'timeago');

function timeago() {
    global $post;
    $date = $post->post_date;
    $time = get_post_time('G', true, $post);
    $time_diff = time() - $time;
    if ( $time_diff > 0 && $time_diff < 24*60*60 )
        $display = sprintf( __('%s ago'), human_time_diff( $time ) );
        $display = date(get_option('date_format'), strtotime($date) );

    return $display;

Source: Cats Who Code – Top WordPress Hacks of Early 2010

This function will display the time since the post was posted – much like how Twitter does with tweets.