php-通过Google Calendar API获取Google Calendar的时区
作者:互联网
我正在使用Google Calendar API在我的客户Google日历中插入事件.我想在其日历的时区中插入事件,但是目前我只能通过Google Calendar API使用一个时区.
如何使用Google Calendar API获取特定Google日历的时区?
现在,我正在使用以下代码将事件添加到Google日历:
$eventName='You have ListingAppointments.com Appointment';
$Address='testing-456';
$Ausers='test48@gmail.com';
if ($client->getAccessToken()) {
$_SESSION['token'] = $client->getAccessToken();
//print_r($events);
$event = new Google_Event();
$event->setSummary($eventName);
$event->setLocation('testing234');
$start = new Google_EventDateTime();
$start->setDateTime('2013-07-19T10:25:00.000-07:00');
//print_r($start);
$event->setStart($start);
$end = new Google_EventDateTime('2013-07-19T10:25:00.000-07:00');
$end->setDateTime($end);
//print_r($end);
$event->setEnd($end);
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail($Ausers);
$attendees = array($attendee1);
$event->attendees = $attendees;
$createdEvent = $cal->events->insert('primary', $event);
print_r($createdEvent);
}
解决方法:
尝试以下代码:-$calendar = $cal-> calendars-> get(‘primary’); echo $calendar-> getTimeZone();
第一行使用getTimeZone()方法获取主日历,第二行获取时区.
或只是$cal-> calendars-> get(‘primary’)-> getTimezone();
标签:google-calendar-api,php 来源: https://codeday.me/bug/20191030/1969381.html