4
我有爲給定的mailid向Google日曆添加事件的代碼。將事件添加到Google日曆時的時差
問題是,當我嘗試添加事件時存在時間差異問題。
例如,如果我將以下內容添加到日曆03/21/2012 8:00AM
,則在網絡上查看的日曆條目中的時間設置爲17:30
。
這裏是我的代碼:
$gmail = '[email protected]';
$gpwd = '1233';
$datetime1 = strtotime('03/21/2012 8:00AM');
$date1 = date("Y-m-d", $datetime1);
$idg = add_to_calendernow1($gmail,$gpwd,$id,$date1,$datetime1);
function add_to_calendernow1($gmail,$gpwd,$ticket,$date,$timestamp){
if($gmail){
/* Change the below path with correct path class1.php and class2.php are in the includes directory */
include('includes/class1.php');
include('includes/class2.php');
$email = $gmail;
$password = $gpwd;
$altEmail = $gmail;
$login = new GoogleClientLogin($email, $password, GoogleClientLogin::$CALENDAR_SERVICE, APP_NAME);
$cal = new GoogleCalendar($login);
$cal->altEmail = $altEmail;
$content = "Ticket #".$ticket." scheduled now";
$entryData = $cal->addEvent(array(
"title"=> "Ticket #".$ticket." Scehduled An Item",
"content"=> $content,
"where"=> "",
"startTime"=> $timestamp,
"endTime"=> $timestamp
));
$id_now = explode('feeds/',$entryData['id']);
$sec_id = $id_now[1];
$id_id = explode('/',$sec_id);
return $id_id[0];
}
}
的GoogleClientLogin和Google日曆類來自這個博客帖子:
http://mark.biek.org/blog/2010/07/addingdeleting-events-with-the-google-calendar-api/
有沒有人有什麼可能會導致這什麼想法?
Google日曆的時區設置爲東部標準時間,服務器位於美國。
在我的代碼中還有其他事情需要做,以確保時間正確地結轉?