Edit report at http://bugs.php.net/bug.php?id=53473&edit=1
ID: 53473 Updated by: ahar...@php.net Reported by: giecrilj at stegny dot 2a dot pl Summary: Allow system timezone on glibc-based systems -Status: Open +Status: Duplicate Type: Bug Package: Date/time related Operating System: Linux PHP Version: 5.3.3 Block user comment: N Private report: N New Comment: This is by design, per bug #39142. Previous Comments: ------------------------------------------------------------------------ [2010-12-04 21:07:38] giecrilj at stegny dot 2a dot pl 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 this bug report at http://bugs.php.net/bug.php?id=53473&edit=1