Determines the difference between two timestamps.

This is a fantastic function, especially since it has been in WordPress since version 1.5! If you want to display a relative date in a human-readable format, like “5 minutes ago” or “one month ago,” try the human_timed_diff() function.

Example 1

[php]
$diff = human_time_diff( ‘2012-05-05 12:05:00’, ‘2012-05-05 12:10:00’ );
echo ‘This comment was submitted ‘ . $diff . ‘ago’;

// Output: This comment was submitted 5 minutes ago
[/php]

Examples 2

[php]
To print an entry’s time ("2 days ago"):
<?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?>
[/php]

Examples 3

[php]
For comments:
<?php echo human_time_diff( get_comment_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?>
[/php]