We’ve been struggling for a while now with an unexplained three hour offset in log files and error messages created by QuestionMark Perception – commercial software which runs under PHP on IIS. I thought it would worth sharing a few gotchas in trying to pin down what was causing the problem:
1. Make sure you are looking for the
setting in the correct php.ini file (there are usually at least two) – you can identify which is being used by looking in IIS Manager | PHP Manager under ‘PHP Settings’ | ‘Configuration file’.
2. Use phpinfo to check what timezone PHP is reporting. You can either use the function –
– in an otherwise empty php page or by choosing IIS Manager | PHP Manager and then under ‘PHP Setup’, choose ‘Check phpinfo()’.
3. Be aware that the windows PHP installer adds a section at the end of the php.ini file:
. A date.timezone setting in this section will override any earlier date.timezone settings.
4. If you make any changes to php.ini, you will need to restart IIS in order for them to be picked up. At the command prompt, type
or use IIS Manager.
5. If it’s your own code you can override the value in php.ini with:
This is useful if you can’t restart IIS on e.g. a production server.