sylvest Posted April 6, 2017 Posted April 6, 2017 (edited) Hi,The web pages that I am currently writing (in PHP) report errors including a timestamp to the file /home/xxxxxxx/logs/main.log. The times reported are UTC. I have the following in my PHP:date_default_timezone_set("Europe/London");which I believe should set it to use the stated timezone throughout my site, which should (I think) recognise DST, so should now report UTC +01:00. It is not doing so.I thave changed the PHP code that writes to the log file to this:$logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " ....and it is now outputting:[06-Apr-2017 16:19:50 UTC 0 +00:00 GMT] on localhost L_TRACE at line 96 ....from which you can see that it thinks it is outputting UTC. I think the problem is that it is just not switching to the timezone I have requested.Please can you suggest why it is not outputting GMT/DST, i.e. UTC +01:00, or what I need to do to find out what is causing this problem?Thank you - Rowan Edited April 7, 2017 by TCH-Bala edited out username Quote
TCH-Bryan Posted April 7, 2017 Posted April 7, 2017 Hi Rowan, This issue should now be resolved. Your local version of php.ini (/home/USERNAME/php.ini) was overriding the date_default_timezone_set function. I have changed date.timezone value in that file to "Europe/London". Could you please try again and let me know if the problem persists? Quote
sylvest Posted April 10, 2017 Author Posted April 10, 2017 (edited) Bryan, Thanks for your help with this. Now the system error log is reporting the correct time in GMT with DST, but the PHP log is still reporting GMT without DST. I have removed all the calls to date_default_timezone_set() in my PHP files but it is still the same. To generate the PHP log my code is: $logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " . $loglevels[$level] . " " . $msg . " at line " . $line . " in file " . $file . PHP_EOL; The text produced in the log file is (example): [10-Apr-2017 11:47:18 UTC 0 +00:00 GMT] on localhost L_TRACE Redirecting to Location: http://www.sylvesterbradley.org/swchoir/welcome.php using header at line 302 in file /home/xxx/include/initialise.php Any idea why it is doing this, or what I can do to correct it? Please can you explain how the date.timezone = in the PHP.ini file interacts with the date_default_timezone_set() in a PHP file. Does one override the other? Which takes precedence? Or if I use one, does using the other cause an error? Which way round? Ideally I would like the PHP file to determine which timezone it uses, if necesary overriding what is written in the PHP.ini file, since one section of the web site may require a different timezone than another. Or I may want to reflect the timezone of the particular user that has logged on. Thanks - Rowan Edited April 11, 2017 by TCH-Bala Please do not add sensitive information like domain and home directory paths on a public forum Quote
TCH-Bala Posted April 11, 2017 Posted April 11, 2017 Scripts default to the php parameters including timezone as set on the server's php.ini config. If you set a local php.ini (this needs to be set via cpanel -> MultiPHP INI Editor), then the default values will be overridden by what is set on the local ini file. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.