Posted by on 27 August 2013 07:53 PM
The timezone used on your linux system is set in the /etc/localtime file, you simply need to replace this file with the correct timezone file for the timezone you need.
First, make a backup of the existing localtime file.
mv /etc/localtime /etc/localtime.bkp
Next, create the symlink:
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime (this is for Central timezone)
Then test your change by Running the "date" command from command line, it should report the correct time, date, and timezone that you set it to.
You can also run "hwclock" to view the hardware clock and verify it matches the correct time displayed by the "date" command, if its not you can correct the hardware clock by running "hwclock --systohc" which will set the hardware clock to the systems time or vice versal "hwclock --hctosys" to set the system time from the hardware clock.
Please note, this will not work on VPS systems as the date/time is set by the hardware node.
PHP's timezone is set by changing or adding the date.timezone variable in /usr/local/lib/php.ini or your custom php.ini if your using one. Changing the system time zone above does not apply to PHP if the date.timezone setting in PHP is set to something different than the system.
Just add the above line to the end of the php.ini file (with your timezone) and restart Apache for the change to take effect, if your using a custom php.ini file then no restart is necessary.
Supported Timezones in PHP
Full list of countries/zones can be found here http://php.net/manual/en/timezones.php