Apache logs - time setup different to server or php times

November 14, 2014 1.6k views

Hoping someone can shed some light for me on a question I've been trying to answer now for days.
I am running CentOS 6.5 x64 in Amsterdam using VestaCP and multiple WP sites without problem.
My question is regarding the timestamp on the apache logs which is different to the server time and the php.ini time and here is an example

  1. [14/Nov/2014:08:47:09 -0500] apache log /var/log/httpd/access_log
  2. Fri Nov 14 14:47:09 CET 2014 ssl terminal command "date"
  3. 14:47:09 php command "echo date('H:i:s');"

Item 1 is in fact one hour behind items 2 and 3 and looks to be timing from New York maybe and I appreciate the -0500 makes it GMT?
Having set the timezones for Centos and also for php.ini for Amsterdam is there any way to to get item 1 to match them or at least to be in sync with them?

1 Answer

How did you set the system time? I just did a little testing, and it seems that using tzselect will update the system time but Apache won't reflect that. It is if I manually run:

ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime
service httpd restart

Most likely this is due to the init script starting Apache not reading the environmental variable from the user session.

  • Thank you so much - spot on the nail.
    I just used used tzselect and then configured the php.ini
    After setting up with the tzselect i didn't realize about setting a link to etc/localtime (I'm still learning)

    All now working as should be but be aware the line
    service restart httpd should be service httpd restart

  • Ops. Fixed the typo above. Glad to hear you got it working!

Have another answer? Share your knowledge.