Loading...

Knowledge Base

Change Your System Time Zone

Did you find this article helpful?
Copy Link

 
* Your feedback is too short
Share this article

The time zone used on your Linux system is set in the '/etc/localtime' file. To replace the file with the correct time zone file, you need the following:

  1. Make a backup of the existing localtime file mv /etc/localtime /etc/localtime.bkp.

  2. Find your correct time zone file in /usr/share/zoneinfo.

  3. Create the symlink: ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime 
    Note: this configuration is for the Central timezone.

  4. Test your time zone change by running the 'date' command from the command line.

    Now, it should report the correct time, date, and time zone that you set it to.

You can also run the 'hwclock' command via the command line to view the hardware clock and verify that it matches the correct time displayed by the 'date' command. If the two time zones don't match, then correct the hardware clock by running the 'hwclock --systohc' command, which will set the hardware clock to the system time or vice versa ('hwclock --hctosys') to set the system time from the hardware clock.

Change PHP's Timezone

PHP's time zone is set by changing or adding the date. Timezone variable in /usr/local/lib/php.ini or your custom php.ini file if you use 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.

Example: date.timezone="America/Chicago"

Add the above line to the end of the php.ini file (with your time zone) and restart Apache for the change to take effect. If you use a custom php.ini file, no restart is necessary.

Supported Timezones in PHP

Africa
America
Antarctica
Arctic
Asia
Atlantic
Australia
Europe
Indian
Pacific
Others 

A complete list of countries/zones can be found here http://php.net/manual/en/timezones.php.

Did you find this article helpful?
Copy Link

 
* Your feedback is too short

Loading...