创建新事件时事件时间不匹配
Event time mismatches when creating new events
当我向我的日历添加活动时,日期时间 start/end 出现问题。
这是我使用的代码:
$event = new Google_Service_Calendar_Event(array(
'summary' => 'event title',
'description' => 'event description',
'start' => array(
'dateTime' => '2017-02-05T00:00:00-08:00',
'timeZone' => 'Europe/Paris',
),
'end' => array(
'dateTime' => '2017-02-05T00:00:00-13:00',
'timeZone' => 'Europe/Paris',
)
));
$event = $cal->events->insert($room_calendar_id, $event);
此代码应在我的日历中添加一个事件,从 08:00 开始,到 13:00 结束。事实上,事件是从 10:00 开始添加的,在 15:00 结束。
它将日期时间增加 2 小时。
您认为错误来自时区吗?
您将当地时间与时区偏移混淆了。
2017-02-05T00:00:00-08:00 => 2017-02-05T08:00:00+01:00
2017-02-05T00:00:00-13:00 => 2017-02-05T13:00:00+01:00
两个值都应该有一个 +01:00
偏移量,因为这是 Europe/Paris
.
事件发生时有效的 UTC 偏移量
当我向我的日历添加活动时,日期时间 start/end 出现问题。
这是我使用的代码:
$event = new Google_Service_Calendar_Event(array(
'summary' => 'event title',
'description' => 'event description',
'start' => array(
'dateTime' => '2017-02-05T00:00:00-08:00',
'timeZone' => 'Europe/Paris',
),
'end' => array(
'dateTime' => '2017-02-05T00:00:00-13:00',
'timeZone' => 'Europe/Paris',
)
));
$event = $cal->events->insert($room_calendar_id, $event);
此代码应在我的日历中添加一个事件,从 08:00 开始,到 13:00 结束。事实上,事件是从 10:00 开始添加的,在 15:00 结束。 它将日期时间增加 2 小时。
您认为错误来自时区吗?
您将当地时间与时区偏移混淆了。
2017-02-05T00:00:00-08:00 => 2017-02-05T08:00:00+01:00
2017-02-05T00:00:00-13:00 => 2017-02-05T13:00:00+01:00
两个值都应该有一个 +01:00
偏移量,因为这是 Europe/Paris
.