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”.


human_time_diff( $from, $to );



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

Default: None


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

Default: ”

Return Values


Human readable time difference.


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.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: