ID: 35660 Updated by: [EMAIL PROTECTED] Reported By: Bjorn dot Wiberg at its dot uu dot se -Status: Open +Status: Assigned Bug Type: Date/time related Operating System: IBM AIX 5.2.0.0 ML5 PHP Version: 5.1.1 -Assigned To: +Assigned To: derick
Previous Comments: ------------------------------------------------------------------------ [2005-12-13 20:44:51] Bjorn dot Wiberg at its dot uu dot se Hi again! Setting date.timezone in php.ini doesn't help -- as PHP still reverts to UTC when it considers the TZ variable invalid. Unsetting TZ works for PHP, but breaks things for other software (notably Apache 2, which then logs using UTC instead of the correct local time). We're using PHP as an Apache DSO (module), so there seems to be no possiblity of separating those two in terms of the TZ variable. Using mod_env's UnsetEnv or SetEnv doesn't work (only for CGI scripts and SSI pages). Of course, setting the desired timezone with date_default_timezone_set() works, as does putenv('TZ=Europe/Stockholm'), but breaks code which relies on that the date/time returned by the date functions are using local time. No chance of getting support for the AIX-style TZ format in a future version? No chance of getting a "revert-to-date.timezone-setting-if-TZ-is-unusable" behavior of the date functions in a future version? Best regards, Björn ------------------------------------------------------------------------ [2005-12-13 20:17:14] [EMAIL PROTECTED] Of course not. It's not the correct one. Just use the php.ini option. ------------------------------------------------------------------------ [2005-12-13 20:04:09] Bjorn dot Wiberg at its dot uu dot se Another quick note to clarify that the timestamp measured in UTC of course is correct -- the wording "correct" in the output of my script might be a bit misleading; the problem is that PHP doesn't recognize the AIX timezone contained in the TZ variable, nothing else. ------------------------------------------------------------------------ [2005-12-13 19:37:39] Bjorn dot Wiberg at its dot uu dot se Just a quick note to tell that PHP does log this fact in the Apache error log: PHP Notice: date(): Timezone setting (date.timezone) or TZ environment variable contains an unknown timezone in /apache/htdocs/... ------------------------------------------------------------------------ [2005-12-13 19:28:32] Bjorn dot Wiberg at its dot uu dot se Description: ------------ PHP does not understand the notion of the TZ environment variable that IBM AIX uses, and defaults to the UTC time zone if an "incorrect" TZ value is encountered. The format of the TZ variable, and the allowed values, can be found here: http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.aix.doc/files/aixfiles/environment.htm If this could be considered for future releases, that would be a great relief. As many (all?) other software on the system seem to use the TZ correctly. Otherwise, it would be great if the date.timezone setting would act as a fallback in case the TZ environment variable is considered invalid by PHP. And, perhaps, that this is clarified in the documentation (http://se.php.net/manual/sv/function.date-default-timezone-get.php); i.e., that an incorrect TZ value directly yields a "UTC" timezone setting. Reproduce code: --------------- System environment configuration file /etc/environment contains: TZ=NFT-1DFT,M3.5.0/02:00:00,M10.5.0/03:00:00 httpd.conf contains: php_value date.timezone "Europe/Stockholm" PHP script that displays the reverting-to-UTC behavior of PHP: <?php // putenv('TZ=NFT-1DFT,M3.5.0/02:00:00,M10.5.0/03:00:00'); echo 'TZ is: ' . getenv('TZ') . '<BR>'; echo 'date.timezone is: ' . ini_get('date.timezone') . '<BR>'; echo 'date_default_timezone_get() returns: ' . date_default_timezone_get() . '<BR>'; echo 'Current time is: ' . strftime('%T') . '<BR>'; echo '<BR>'; echo 'Forcing the correct timezone (' . ini_get('date.timezone') . ')...<BR>'; date_default_timezone_set(ini_get('date.timezone')); echo 'Correct current time is: ' . strftime('%T') . '<BR>'; ?> Expected result: ---------------- That the timezone is picked up and understood by PHP. This would equal the "Europe/Stockholm" timezone setting. That is: TZ is: NFT-1DFT,M3.5.0/02:00:00,M10.5.0/03:00:00 date.timezone is: Europe/Stockholm date_default_timezone_get() returns: Europe/Stockholm Current time is: 19:20:10 Forcing the correct timezone (Europe/Stockholm)... Correct current time is: 19:20:10 Actual result: -------------- TZ is: NFT-1DFT,M3.5.0/02:00:00,M10.5.0/03:00:00 date.timezone is: Europe/Stockholm date_default_timezone_get() returns: UTC Current time is: 18:20:10 Forcing the correct timezone (Europe/Stockholm)... Correct current time is: 19:20:10 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35660&edit=1