Determines the difference between two timestamps.
The difference is returned in a human readable format such as "1 hour", "5 mins", "2 days".
<?php human_time_diff( $from, $to ); ?>
To print an entry's time ("2 days ago"):
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
Internationalized version:
<?php printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ); ?>
For comments:
<?php printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_comment_time( 'U' ), current_time( 'timestamp' ) ) ); ?>
Since: 1.5.0
human_time_diff()
is located in wp-includes/formatting.php
.
Time Functions: current_time(), human_time_diff(), the_time(), get_the_time(), comment_time()