date_default_timezone_set call in apiClient.php

120 views
Skip to first unread message

Santiago

unread,
Jan 12, 2012, 10:16:48 AM1/12/12
to google-api-php-client
Hello!

on apiClient.php line 27 the default timezone is changed to UTC

if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('UTC');
}

my application relies on the current established timezone, and
naturally this presents a problem for me. Why is the default
timezone being changed here? I see no important calls to date
functions to justify this, so I'd like to know why this is needed and
if I can remove it safely.

Thanks!

Chirag Shah

unread,
Jan 12, 2012, 1:36:14 PM1/12/12
to google-api...@googlegroups.com
Hey Santiago,

Thank you for reporting this issue.  I've committed a change so date_default_timezone_set('UTC') only gets called when date.timezone isn't populated.
It is also available in google-api-php-client-0.4.8.2.



On Thu, Jan 12, 2012 at 7:16 AM, Santiago <santiag...@gmail.com> wrote:
Hello!

on apiClient.php line 27 the default timezone is changed to UTC

if (function_exists('date_default_timezone_set')) {
 date_default_timezone_set('UTC');
}

my application relies on the current established timezone, and
naturally this presents a problem for me.   Why is the default
timezone being changed here?   I see no important calls to date
I received several complaints about php complaining about "it is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting..."
and several people had issues updating their php.ini file, etc.

We need date.timezone because we use strtotime to parse the Expires HTTP header.
 
functions to justify this, so I'd like to know why this is needed and
if I can remove it safely.
You can remove it safely.

Thanks!

Marko Tukiainen

unread,
Jun 28, 2012, 8:55:09 AM6/28/12
to google-api...@googlegroups.com
Hello,

Sorry to resurrect an old thread, but having just spent several hours debugging what seemed to be the bogeyman changing the timezone setting and causing quite a lot of complaints I finally tracked down the culprit to this. 

I would like to suggest that this be changed so that the timezone change is automatically reset back to the original setting. None of the php.ini files on any of my servers set date.timezone, instead the system default is used. So, when this library calls date_default_timezone_set('UTC') bad things start to happen. 

Thanks, 
Marko
Reply all
Reply to author
Forward
0 new messages