如果您想创建一个为期一天的事件,请使用 $start->setDate() 而不是 $start->setDateTime()。
创建一个为期一天的活动
$event = new Event();
$event->setSummary("Summary of the event");
$event->setLocation("Location");
$start = new EventDateTime();
$start->setDate("2013-01-01");
$event->start=$start;
$end = new EventDateTime();
$end->setDate("2013-01-02");
$event->end=$end;
$calendarId="primary"; // primary represents your calendar
$createdEvent = $cal->events->insert($calendarId, $event);
在给定的持续时间内创建事件
$event = new Event();
$event->setSummary("Summary of the event");
$event->setLocation("Location");
$start = new EventDateTime();
$start->setDateTime("2013-01-01T0:00:00.000+00:00");
$event->start=$start;
$end = new EventDateTime();
$end->setDateTime("2013-01-01T0:01:00.000+00:00");
$event->end=$end;
$calendarId="primary";
$createdEvent = $cal->events->insert($calendarId, $event);