0

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

Saravanan Sampathkumar
  • 3,201
  • 1
  • 20
  • 46
cardi777
  • 563
  • 2
  • 9
  • 22

2 Answers2

1

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.

Community
  • 1
  • 1
Koala Yeung
  • 7,475
  • 3
  • 30
  • 50
0

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

Community
  • 1
  • 1
EddyTheDove
  • 12,979
  • 2
  • 37
  • 45
  • I think the warning is about "managing recurring events". It does says "If you stick to creating events with a name and a date you should be fine." – Koala Yeung Feb 21 '17 at 05:04
  • Well, he is trying to insert `repeat` event. Is it different from recurring? – EddyTheDove Feb 21 '17 at 05:06
  • I believe the official name for "repeat event" in Google Calendar is [Recurring Events](https://developers.google.com/google-apps/calendar/recurringevents). Also, the data he supplied is an event definition with `recurrence` rules, which basically is a recurring event. (Names are confusing ...) – Koala Yeung Feb 21 '17 at 05:10
  • i have eventually gotten it to work, but im having difficulty with timezones so far – cardi777 Feb 22 '17 at 04:44