I'm not sure if this is a question for serverfault or stackoverflow but it seems like it has a lot to do with server config.

We have a server in chicago and the server's clock is on chicago time. But since the business is located in California, it would seem to make sense to use pacific time.

What happens when server time is Chicago, and php.ini directive date.timezone is set to "America/Los_Angeles"? How will that affect logs written to mysql, error logs, etc?

I've looked at the Apache error log and, as I expected, the php directive does not affect it. Times are all servertime.



PHP scripts and PHP itself will use Pacific Time, but everything else (including Apache and MySQL) will use the system defined timezone.

| improve this answer | |

Only PHP will use the different timezone.

Since you also asked how this will affect logs written to MySQL (and not by MySQL):
That depends on your application.

If you are logging to MySQL and use MySQL functions (e.g. NOW()) it will use to system timezone.
If you are generating dates via the PHP date() function and write those to MySQL, these would be in the php.ini specified timezone.
And if you are mixing those to store times you obviously have some problems...

I always try to have the same timezone across all applications on one server.

| improve this answer | |
  • So, if your server was in Chicago but your business was based in California, would you set the server time to California time? Is there any reason to keep it on Chicago time? – Buttle Butkus Jun 10 '12 at 23:00
  • I would leave it in Chicago and try to make the App timezone aware/configurable. There are no real technical reasons to put the server into the correct time zone. If you don't, it adds confusion when correlating logs from your ISP with local logs and it must be very clear to anyone working on that server which timezone it is in and why it should stay in there ("I fixed the timezone for you!" and suddenly all nightly cronjobs kick off during the day...). – faker Jun 10 '12 at 23:28

It should be added, that php's own error_log (if specified) records in UTC+0, regardless of the date.timezone setting.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.