0
votes

I have the following events in my test google calendar:

  • All day event on the 20. February
  • Timed event on the 21. February from 10am till 11am

I do a request against the Google calendar API with the parameters timeMin = 2018-02-21T00:00:00+00:00 and timeMax = 2018-02-21T23:59:59+00:00. All is working fine when the calendar has the timezone UTC. Only the timed event is returned. But when I set the calendar timezone to something like "(GMT-06:00) Central Time" then the result does include also the all day event.

Is there a way to fetch the events ignoring the timezone for all day events? All day events are not bound to a timezone from my understanding and should not be included at anytime when the timeMin parameter is not from the day of the all day event.

1
All-day events effectively start at midnight. So in a way they are bound to the timezone - after all, midnight in one part of the world is not midnight in another part. So if your calendar has a timezone offset but your query parameter doesn't, then yeah your results may not be quite what you expected.ADyson
Aggree with @ADyson, also I think you need to use a valid timeZone. e.g. (Europe/Andorra) if I understand it right. You can use try it in the documentation for testing.MαπμQμαπkγVπ.0
If that would be the case, should then Google not offer for the all day event to set a timezone the same way as with timed events? Even in ics (ical) files you don't define a timezone for all day events. I can't find the link but in barely remember that I was reading somewhere in the past that all day events are not bound to a timezone.Laoneo

1 Answers

0
votes

You just need to use timeZone param in your query and google will do the needed conversion

'timeZone' => 'your time zone'

$optParams = array(
        'maxResults' => $maxResults,
        'orderBy' => 'startTime',
        'singleEvents' => TRUE,
        'timeMin' => $timeMin,
        'timeMax' => $timeMax,
        'timeZone' => $timezone
        );