Function Reference: human time diff

Determines the difference between two timestamps.

The difference is returned in a human readable format such as “1 hour”, “5 mins”, “2 days”.

Usage

human_time_diff( $from, $to );

Parameters

$from

(integer) (required) Unix timestamp from which the difference begins.

Default: None

$to

(integer) (optional) Unix timestamp to end the time difference. Default becomes time() if not set.

Default: ”

Return Values

(string)

Human readable time difference.

Examples

To print an entry’s time (“2 days ago”):

echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';

For comments:

echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' ago';

via Function Reference/human time diff « WordPress Codex.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: