将事件添加到Google日历时的时差
问题描述:
我有为给定的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日历的时区设置为东部标准时间,服务器位于美国。
在我的代码中还有其他事情需要做,以确保时间正确地结转?