googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.22k stars 3.52k forks source link

Google Calendar Event List Timezone issue #2468

Closed goear closed 7 months ago

goear commented 1 year ago

While using Google Calendar's Event List API, I encountered an inconsistency in timezone settings. On Google's online API interface, setting 'timeZone' to 'Etc/UTC' correctly returns events in that timezone. However, in my PHP implementation, despite setting 'timeZone' to 'Etc/UTC', events return in the 'Europe/Madrid' timezone, the calendar's default.

In the Event List documentation I read

timeZone string Time zone used in the response. Optional. The default is the time zone of the calendar.

If I use the "try this" in the documentation page, I select 'Etc/UTC' value and the events are returning with the correct timeZone, in this case Etc/UTC.

The problem occurs when I try the same in the google API for PHP

$optParams = [ 'syncToken' => $config->syncToken(), 'timeZone' => 'Etc/UTC' ];

$results = $service->events->listEvents($externalCalendar, $optParams);

In the response for events I'm receiving them in Europe/Madrid timezone (the calendar timezone), instead of Etc/UTC.

ejlalzadeh commented 10 months ago

Yes I have the same problem when calling google api's in postman

yash30201 commented 8 months ago

Hi @goear ,

Thank you so much for bringing such an issue to our notice. Sorry for this late reply I tried reproducing it but it's giving me correct responses.

Without Timezone With Timezone Etc/UTC
{"timezone" => "Asia/Kolkata", "time" => "2023-11-27T16:30:00+05:30"} {"timezone" => "Asia/Kolkata", "time" => "2023-11-27T11:00:00Z"}

This is the expected behaviour as the same is happening in the API explorer. Can you try it once again to see if the same is still happening to you?

yash30201 commented 7 months ago

Closing this due to inactivity. Please feel free to open if this issue still exists.