使用时间的正确时间格式Max在PHP中检索Google日历事件


Right time format of using timeMax retrieving Google Calendar Events in PHP?

我试图使用PHP检索Google日历事件以进行某些分析。我使用singleEvents= True设置将重复发生的事件扩展为单个实例。为了避免检索无限重复事件,我尝试将事件开始上限设置为 2015-06-01。

这是我使用的代码:

$eventList = $cal->events->listEvents($tempCal["id"], array(maxResults   =>5000,singleEvents => True,timeMax => '2015-06-01T00:00:00-04:00'));

但似乎 timeMax 参数不起作用。

我尝试了其他时间格式"2015-06-01T00:00:00Z",但它也不起作用。

但是,我使用 Web 浏览器尝试了相同的字符串,它使用 https://developers.google.com/google-apps/calendar/v3/reference/events/list 检索了 2015-06-01 之前的所有事件

我的 timeMax 格式出了什么问题?

为我工作的解决方案(排序和时间限制):

/* retrieve events for today */
$start = date(DateTime::ATOM, mktime(0,0,0,date('m'), date('d'), date('Y')));
$end = date(DateTime::ATOM, mktime(23,59,59,date('m'), date('d'), date('Y')));
$eventOptions = array("orderBy"=>"startTime",
                      "singleEvents"=>true,
                      "timeMin"=>$start,
                      "timeMax"=>$end);
$events = $service->events->listEvents($calendar_id, $eventOptions);