From:
Operating system: Linux
PHP version: 5.3.3
Package: Date/time related
Bug Type: Bug
Bug description:Allow system timezone on glibc-based systems
Description:
------------
âPHP Warning: date(): It is not safe to rely on the system's timezone
settings.â
The warning is ridiculous. It is not safe to drive a car, yet most people
do
it every day. And the remedy offered creates more problems that it solves
(AFAIK, it tries to solve the problem that the system administrator is
incompetent, which is not a problem of most system administrators, and it
is
none of PHPâs business after all).
There are several workarounds for this warning, and none of them is good.
The workaround contained in the warning actually does more harm than good.
There are numerous places where a configuration parameter can be set,
including
live code. The configuration files for various virtual servers can be
different. If the time zone changes, e.g. when the application uses an
outsourced server, ALL these places must be updated. There is no standard
way
to specify sysconf change triggers, and even if there was one, the trouble
of
doing is not justified by the advantage of specifying the time zone for
PHP
separately (which is none).
The workaround of calling the date_default_timezone_set() function is more
appealing but it suffers the same disadvantages. Because it must be done
for
every single script that uses date, the only reasonable place to put it is
in a
script preloaded to PHP. However, there is no reasonable way to reliably
configure such a script system-wide, so it might work and it might also
fail.
Again, the advantage to implementing this tautology is NONE.
There is also a third workaround, not mentioned in the warning message, to
set
the environment variable TZ:
TZ="$(date '+%Z')"
This is least pain but setting this environment variable is EXPLICITLY
DISCOURAGED by the documentation of GNU C library.
There is also no COMPILE-TIME SETTING to disable this warning. Please
provide
one and please turn it on when PHP is to be linked against glibc. Thank
you.
Test script:
---------------
<?php echo date('r'), "\n"; ?>
Expected result:
----------------
Sat, 04 Dec 2010 20:15:14 +0100
Actual result:
--------------
PHP Warning: date(): It is not safe to rely on the system's timezone
settings.
You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those methods
and
you are still getting this warning, you most likely misspelled the
timezone
identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in
Command
line code on line 1
Sat, 04 Dec 2010 20:15:14 +0100
--
Edit bug report at http://bugs.php.net/bug.php?id=53473&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53473&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53473&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53473&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53473&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53473&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53473&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53473&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53473&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53473&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53473&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53473&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53473&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53473&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53473&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53473&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53473&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53473&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53473&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53473&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53473&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53473&r=mysqlcfg