Created
October 14, 2012 06:45
-
-
Save reinforchu/3887633 to your computer and use it in GitHub Desktop.
This is a function to convert local time to time format for twitter API.
This file contains 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
/** | |
* Convert local time to time format for twitter API. | |
* | |
* @param timeStamp Time format for twitter API. | |
* @return Local time. Depends on the regional settings of the server and time. | |
*/ | |
public static function convertLocalTime($timeStamp) { | |
if (isset($timeStamp) === FALSE) return FALSE; | |
sscanf($timeStamp, "%s %s %d %s %s %d", $week, $month, $day, $time, $gmt, $year); | |
$rcf2822 = "{$week}\054\040{$day}\040{$month}\040{$year}\040{$time}\040{$gmt}"; | |
$unixEpoch = strtotime($rcf2822); | |
$localTime = date('r', $unixEpoch); | |
return $localTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a function to convert local time to time format for twitter API.
Format examples:Sun Oct 14 06:09:28 +0000 2012
The return value is a format of RCF2822, please change accordingly.