[php-maint] Timezone querying

Philipp Kempgen philipp.kempgen at amooma.de
Wed Mar 17 21:50:21 UTC 2010

Ondřej Surý schrieb (am 17.3.10 22:00):
> 1. Added overhead when timezone is not set -> I don't think we should
> really do anything in here. It's a simple matter of adding
> date_default_timezone_set("xxx/yyy") to your application. After adding
> this call PHP will use that value as first in guess_timezone().
> However we could put something about it to README.Debian.

Random thoughts:

Hardly anyone actually reads ReadMe files.
(Of course it's their fault, but ...)

In order to write portable code you need
date_default_timezone_set( @date_default_timezone_get());
anyway no matter whether Debian's PHP actually triggers a notice/
warning or not.

Suppressing errors by "@" causes a slight slowdown but that cannot
be avoided, see above.

Note that specifying a literal timezone in
date_default_timezone_set('xxx/yyy') will never happen in a portable

I don't know what Debian's PHP currently does but if it guesses
the system's timezone on every invocation of date() (vs. once per
interpreter invocation) and thus causes a slowdown without triggering
a warning then that might even be worse than the strange default
behavior from upstream.

Can this be fixed be the upstream?

Ugly alternative solution: How about a daily cron job that sets
date.timezone (in /etc/php5/*/php.ini) to
@date_default_timezone_get() resp. /etc/timezone ?
(No, I'm not saying this is the way to go. Just an idea.)

    Philipp Kempgen

More information about the pkg-php-maint mailing list