ID: 45191 User updated by: info at organicdata dot co dot za Reported By: info at organicdata dot co dot za Status: Bogus Bug Type: Date/time related Operating System: Centos el5 PHP Version: 5.2CVS-2008-06-05 (snap) New Comment:
Thanks very much for the feedback - I understand that my "bug" interpretation may have been wrong. My concern is really a result of a combination of the following: 1. the PHP recommendations I've seen is that you don't rely on system time zone and set the time zone explicitly in PHP 2. I want to have a single central logging file containing all system errors 3. The custom error handling routine I use does not catch all errors that PHP can throw, some are only captured by the internal error handler used by setting log_errors=On Because of 3, the only way I can achieve 2 that I can see is to set the output file in my custom error handler to be the same as the value set in the inifile parameter error_log. This means that the errors I trap are then inserted into the same file as the ones I am unable to trap due to the limitation of 3 and they occur in a sensible sequence. As per your reply however, the only way for me to ensure that the errors written to the file by my custom error handler have meaningful timestamps relative to the ones written as a result of the log_errors=On parameter means that i have to set my PHP explicit timezone to the same as that of the server. ...which means that I'm setting the value on the server and again in PHP and that if there is some change in the server timezone for whatever reason at a later stage, my log file will become "a mess" of inconsistent timestamps (depending on whether the error written to the file was as a result of my custom error handling routine or whether handled by the internal error logging. ...which in turn from my perspective means that it is in fact dangerous to explicitly set the PHP internal timezone and actually safer to allow everything to rely only on the system timezone - at least this way I can guarantee consistency in the timestamps of the errors written to the log file well that's the way I see it anyway - not sure whether I'm missing something big here thanks again for the feedback Previous Comments: ------------------------------------------------------------------------ [2008-07-14 10:06:39] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is normal. The error log is not *written* by PHP, but by syslog. Syslog doesn't care about PHP's internal timezone, and thus formats the log message according to the system timezone. Just change the system timezone if it's incorrect. ------------------------------------------------------------------------ [2008-06-05 23:50:30] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45191&edit=1