[php-maint] Timezone querying

Ondřej Surý ondrej at debian.org
Thu Mar 18 00:06:34 UTC 2010

> On Thu, Mar 18, 2010 at 00:46, Raphael Geissert <geissert at debian.org> wrote:
> On 17 March 2010 14:17, Filipus Klutiero <chealer at gmail.com> wrote:
>> Sean, let's do that. I'll recap what I wrote in my 3 last mails.
>> Hi all,
>> at the end of February, PHP 5.3 came to me, with an expected number of issues. One issue that annoyed me was that a warning is now triggered if a time-related function is used without having set the timezone in 3 approved ways: the TZ environment variable, the date.timezone PHP directive or calling date_default_timezone_set(). Thankfully, Sean Finney made Debian's PHP quiet this warning - so PHP now relies on the system timezone (PHP was already able to use that as a last recourse, but considered it unreliable, for an obscure reason).
> That actually needs to be fixed, because the results are actually
> incorrect (in spite of the tz foo patch):
> $ cat /etc/timezone
> America/Mexico_City
> $ php -nr 'var_dump(date_default_timezone_get());'
> string(15) "America/Chicago"

Do they have a same timezone abrev? There is a logic in php_date.c
which guesses time from php_localtime_r() call. In my case it converts
Europe/Prague to Europe/Berlin (same timezone - CET).

> What _is_ a problem is that before that's done, the
> /usr/share/zoneinfo directory (and contents) is stat()ed followed by
> lots of string comparisons which in total take some time.

I guess it would be best to build something like a decision tree
there, and cache it somewhere to /var/lib/php5/ and do a maintainance
when tz database changes (or every hour or so).

Ondřej Surý <ondrej at sury.org>

More information about the pkg-php-maint mailing list