cardi777
cardi777

Reputation: 563

google calendar API repeat timezones

Im trying to insert a repeat event using this wrapper: https://github.com/spatie/laravel-google-calendar

Having noproblems with dates, but date+time involves timezones

I keep getting this error:

(400) Missing time zone definition for start time.

[
          "name" => "Test name here"
          "location" => "Brisbane Australia"
          "description" => "Desc here..."
          "timeZone" => "Australia/Brisbane"
          "colorId" => 4
          "startDateTime" => "2017-03-01 14:00:00"
          "endDateTime" => "2017-03-01 15:00:00"
          "recurrence" => ["RRULE:FREQ=DAILY;INTERVAL=1;"]
]

i dont know how to add timezones to these start and end datetime values

Upvotes: 0

Views: 1075

Answers (2)

Koala Yeung
Koala Yeung

Reputation: 7843

According to Google Calendar API documentation, the field start.dateTime (supposedly your "startDateTime" field) is assumbed to be RFC 3339 format. (I assume you have to do the same with endDateTime).

You need to covert the date to that format.

If your raw data is a DateTime object, you can convert it like this:

<?php

$startDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "2017-03-01 14:00:00");
echo $startDateTime->format(DateTime::RFC3339);

Will output:

2017-03-01T14:00:00+08:00

Time zone is included in this format.

Upvotes: 1

EddyTheDove
EddyTheDove

Reputation: 13259

Sorry mate, the package cannot do it.

Limitations

The Google Calendar API provides many options. This package doesn't support all of them. For instance recurring events cannot be managed properly with this package. If you stick to creating events with a name and a date you should be fine.

https://github.com/spatie/laravel-google-calendar#limitations

Upvotes: 0

Related Questions