Reputation: 132
I'm trying to create an event for Google Calendar and I'm getting this error :
Invalid value for: "T" found, can only parse bare date string: 2013-08-22T16:00:00
I also tried adding the timezone offset to my string but I set the timezone manually in the EventDateTime object and according to the documentation it's not neccesary.
Here is how I create my time string :
data['start'] = $("#inputDateStart").val() + "T" + $("#inputTimeStart").val();
And how I set this string in my object
$start = new Google_EventDateTime();
$start->setTimeZone('America/Montreal');
$start->setDateTime($data['start']);
$event->setStart($start);
What am I missing? All day events work fine when I just set my date using the setDate function.
Upvotes: 3
Views: 8616
Reputation: 905
You could simply append the timezone at the end of the time:
$start = new Google_EventDateTime();
$start->setDateTime('2011-06-03T10:00:00-07:00');
$event->setStart($start);
This is GMT-7
So in your case this would work:
$start = new Google_EventDateTime();
$start->setDateTime($data['start']."-4:00");
$event->setStart($start);
:)
Though googles own documentation is old and invalid, you may like to use some of their methods: https://developers.google.com/google-apps/calendar/v3/reference/events/insert
Upvotes: 1
Reputation: 81
I dont know your whole code, but I was getting the same error message when trying to set a date-time on a Google calendar event. When I used the Google online api checker, the date/time format and timezone I was using worked just fine. In the end I found that the problem was because I had done this (using something similar to your notation):
$start = new Google_EventDateTime();
$start->setDate('2013-10-10');
$event->setStart($start);
And then later after finding I had both date and time data available:
$start->setTimeZone('Europe/London');
$start->setDateTime('2013-10-10T19:15:00');
$event->setStart($start);
This gave me the error message you mention. Maybe the Google parser thought it was a day event only and then was confused by additional date/time data. The problem went away when I checked first if I had both date and time data and just did:
$start = new Google_EventDateTime();
$start->setTimeZone('Europe/London');
$start->setDateTime('2013-10-10T19:15:00');
$event->setStart($start);
Upvotes: 5