The timestamps in my PHP error log are being displayed in UTC. I want them to display in my local timezone.
- The
date.timezone
property in my php.ini file is set to the correct timezone. - The output of
phpinfo()
displays the correct timezone. - The output of
phpinfo()
states that the correct php.ini file is loaded. - The server's clock is set to the correct timezone.
All of the websites I've found with Google just say to check those three things.
I'm using Windows Server 2019 and IIS.
Here is an example of what one of the lines in the log file currently looks like:
[28-Dec-2018 14:22:39 UTC] PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\path\media.php on line 694
Update: If I run a PHP script from the command line, and that script generates an error, the log entry DOES have a timestamp in my local timezone.
Best Answer
As per my comment, it sounds like your webserver is using the default log file format (W3C Extended) which uses GMT by default. The MS support page I linked contains two solutions for this.
The temporary solution is to run the following command on your log files:
The best solution, it would seem, is to change the log file format to IIS log file format. I found the following guide in which Step 4 tells you how to do this:
https://docs.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/configure-logging-in-iis
This applies to Windows Server 2012, and Windows 8, but may be similar for your version. Please note the change can be applied at separate levels: Site, Per Site (Server), Per Server (Server).