Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 谷歌日历事件的正确日期格式_Php_Google Api_Google Calendar Api_Google Api Php Client - Fatal编程技术网

Php 谷歌日历事件的正确日期格式

Php 谷歌日历事件的正确日期格式,php,google-api,google-calendar-api,google-api-php-client,Php,Google Api,Google Calendar Api,Google Api Php Client,我正在尝试为Google Calendar创建一个事件,出现以下错误: Invalid value for: "T" found, can only parse bare date string: 2013-08-22T16:00:00 我还尝试将时区偏移量添加到字符串中,但我在EventDateTime对象中手动设置了时区,根据文档,这是不必要的 以下是我如何创建我的时间字符串: data['start'] = $("#inputDateStart").val() + "T" + $("#i

我正在尝试为Google Calendar创建一个事件,出现以下错误:

Invalid value for: "T" found, can only parse bare date string: 2013-08-22T16:00:00
我还尝试将时区偏移量添加到字符串中,但我在EventDateTime对象中手动设置了时区,根据文档,这是不必要的

以下是我如何创建我的时间字符串:

data['start'] = $("#inputDateStart").val() + "T" + $("#inputTimeStart").val();
以及如何在对象中设置此字符串

$start = new Google_EventDateTime();
$start->setTimeZone('America/Montreal');
$start->setDateTime($data['start']);
$event->setStart($start);

我错过了什么?当我使用setDate函数设置日期时,全天活动都可以正常工作。

我不知道您的全部代码,但在尝试设置Google日历事件的日期时间时,我收到了相同的错误消息。当我使用谷歌在线api检查器时,我使用的日期/时间格式和时区工作得很好。最后,我发现问题是因为我这样做了(使用类似于您的符号):

后来在发现后,我有了日期和时间数据:

$start->setTimeZone('Europe/London');
$start->setDateTime('2013-10-10T19:15:00');
$event->setStart($start);
这给了我你提到的错误信息。也许谷歌解析器认为这只是一个白天事件,然后被额外的日期/时间数据弄糊涂了。 当我第一次检查是否同时具有日期和时间数据时,问题就消失了,只是:

$start = new Google_EventDateTime();
$start->setTimeZone('Europe/London');
$start->setDateTime('2013-10-10T19:15:00');
$event->setStart($start);

您只需在时间结束时附加时区:

$start = new Google_EventDateTime();
$start->setDateTime('2011-06-03T10:00:00-07:00');
$event->setStart($start);
这里是GMT-7

因此,在您的情况下,这将起作用:

$start = new Google_EventDateTime();
$start->setDateTime($data['start']."-4:00");
$event->setStart($start);
:)

尽管谷歌自己的文档已经过时且无效,但您可能喜欢使用他们的一些方法:

$start = new Google_EventDateTime();
$start->setDateTime($data['start']."-4:00");
$event->setStart($start);