Last active
May 17, 2017 04:18
-
-
Save wwdboer/4353522 to your computer and use it in GitHub Desktop.
WordPress: Twitter time ago
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Twitter date format example: "created_at": "Mon Jun 27 19:32:19 +0000 2011" | |
function from_apachedate( $date ) { | |
list( $D, $M, $d, $h, $m, $s, $y ) = sscanf( $date, "%s %s %2d %2d:%2d:%2d +0000 %4d" ); | |
return strtotime( "$d $M $y $h:$m:$s" ); | |
} | |
// human_time_diff is a WordPress function | |
echo human_time_diff( from_apachedate( $item->created_at ), current_time( 'timestamp' ) ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment