Skip to content

Instantly share code, notes, and snippets.

@reinforchu
Created October 14, 2012 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reinforchu/3887633 to your computer and use it in GitHub Desktop.
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.
/**
* 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;
}
@reinforchu
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment