human_time_diff « WordPress Codex

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

Source: Function Reference/human time diff « WordPress Codex

Used this little known, but nice gem today. It’s a core WordPress function that gives human relative time from any other datetime in “U” format. Like so:

human_time_diff( date("U", strtotime($twitter_data[$i]->created_at)) );

Leave a Reply