|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-05 23:50 UTC] info at organicdata dot co dot za
Description:
------------
I've noticed that changing the default PHP timezone using either php.ini date.timezone or date_default_timezone_set appears to have no effect on the timestamp used for each entry PHP writes to the file set by php.ini value error_log (when php.ini log_errors = On)
It seems to use the system timestamp regardless. I've done some searching on the web but found nothing and am afraid I'm not sure whether a bug or by design but it seems strange enough to submit here
Reproduce code:
---------------
php.ini
-------
log_errors = On
error_log = myerrors.log
mycode.php
----------
error_reporting(E_STRICT);
date_default_timezone_set("UTC");
SOMEBADCONSTANT
date_default_timezone_set("Africa/Johannesburg");
ANOTHERBADCONSTANT
resulting myerrors.log
----------------------
[06-Jun-2008 00:41:34] PHP Notice: Use of undefined constant SOMEBADCONSTANT - assumed 'SOMEBADCONSTANT' in /prj/mycode.php on line 3
[06-Jun-2008 00:41:34] PHP Notice: Use of undefined constant ANOTHERBADCONSTANT - assumed 'ANOTHERBADCONSTANT' in /prj/mycode.php on line 5
Expected result:
----------------
As Africa/Johannesburg is 2 hours ahead of UTC, I would have expected the second myerrors.log entry to read
[06-Jun-2008 02:41:34] PHP Notice: Use of undefined constant ANOTHERBADCONSTANT - assumed 'ANOTHERBADCONSTANT' in /prj/mycode.php on line 5
And even if the comment is that date_default_timezone_set has no effect, I saw the same when changing date.timezone in php.ini
The error logging appears to ignore it completely and simply use the system time
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
It seems this bug may have reappeared between 5.3.8 and 5.3.9? I have two MS 2008 R2 VMs, built from the same starting images. Both running IIS 7.5, system timezone is set for "Pacific Standard Time" and the TZ environment variable is not set. Machine A : PHP 5.3.8 (cli) (built: Aug 23 2011 12:14:39) (Originally configured with PHP 5.2.17 and subsequently upgraded to 5.3.8) Machine B : PHP 5.3.9 (cli) (built: Jan 10 2012 16:33:06) Their php.ini files are virtually identical, with: log_errors = On date.timezone=America/Los_Angeles error_log="C:\PHP\logs\php53_errors.log" I ran a version of the "mycode.php" from the original bug report on both machines. mycode.php ---------- FIRSTBADCONSTANT; date_default_timezone_set("UTC"); SOMEBADCONSTANT; date_default_timezone_set("America/Los_Angeles"); ANOTHERBADCONSTANT; Machine A php53_errors.log -------------------------- [11-Feb-2012 09:39:18] PHP Notice: Use of undefined constant FIRSTBADCONSTANT - assumed 'FIRSTBADCONSTANT' in C:\Temp\mycode.php on line 2 [11-Feb-2012 17:39:18] PHP Notice: Use of undefined constant SOMEBADCONSTANT - assumed 'SOMEBADCONSTANT' in C:\Temp\mycode.php on line 4 [11-Feb-2012 09:39:18] PHP Notice: Use of undefined constant ANOTHERBADCONSTANT - assumed 'ANOTHERBADCONSTANT' in C:\Temp\mycode.php on line 6 Machine B php53_errors.log -------------------------- [11-Feb-2012 18:06:52 UTC] PHP Notice: Use of undefined constant FIRSTBADCONSTANT - assumed 'FIRSTBADCONSTANT' in C:\Temp\mycode.php on line 2 [11-Feb-2012 18:06:52 UTC] PHP Notice: Use of undefined constant SOMEBADCONSTANT - assumed 'SOMEBADCONSTANT' in C:\Temp\mycode.php on line 4 [11-Feb-2012 18:06:52 UTC] PHP Notice: Use of undefined constant ANOTHERBADCONSTANT - assumed 'ANOTHERBADCONSTANT' in C:\Temp\mycode.php on line 6 The 5.3.9 error reporting seems locked in UTC.I've confirmed the same issue in PHP 5.4.16 using RHEL 7 (the latest stable version for the OS core repo). # grep -r "UTC" . ./httpd/php.log:[29-Jul-2015 00:31:20 UTC] [redacted] # cat /etc/php.ini |grep "York" date.timezone = America/New_York # cat /etc/php.ini |grep "error_log" error_log = /var/log/httpd/php.log This issue does not occur with logs generated directly by rsyslog. # cat /etc/rsyslog.conf |grep Template $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # cat /etc/rsyslog.conf |grep log [...] cron.* /var/log/cron # tail cron Jul 29 10:30:01 [redacted] # date Wed Jul 29 10:38:09 EDT 2015 # timedatectl Local time: Wed 2015-07-29 10:40:22 EDT Universal time: Wed 2015-07-29 14:40:22 UTC RTC time: Wed 2015-07-29 14:40:21 Timezone: America/New_York (EDT, -0400) NTP enabled: yes NTP synchronized: yes Taking a look at main.c, I can see that references to strftime() have in fact been replaced with php_format_date(); despite this the issue remains. I am happy to take a closer look at this, however can anyone confirm if this has been resolved in more recent version? Again, I'm happy to put some work in but just want to check if anyone has resolved or confirmed this as resolved in a more recent version.