1.) Login to your server as root and check your current time zone by running
dateThe ending will tell you the current setting such as UTC
2.) Locate the time zone you wish to use by changing the working directory to the timezone directory:
cd /usr/share/timezone
3.) List the contents of this directory to find the main area you are in:
ls /usr/share/zoneinfo/
4.) Take note of the next directory you want to go to. If your time zone is located in the United States, you would use the America/ directory. Change to that directory:
cd America/5.) Now list the contents of that directory to get the final file name you will use.
ls6.) If the time zone you want to use is MST/MDT, you would select Denver. Take note of the names you found from this step and step 4. The format you will use is <Step 4 Directory>/<Step 6 Filename> removing <> for both
7.) Next overwrite your current timezone file. This is done by executing the following command:
cp /usr/share/zoneinfo/<Step 4 Directory>/<Step 6 File> /etc/localtime8.) You will be prompted to confirm you wish to overwrite the current file. Press y and [Enter]
9.) Edit your system /etc/sysconfig/clock file and update the ZONE value with <Step 4 Directory>/<Step 6 File> within the quotation marks.
vi /etc/sysconfig/clock10.) Upon entering the editing program vim, press the [Insert] key once to edit the file. Once you are done editing the file, press the [ESC] key and then type :wq to write and quit the program.
11.) Finally update your php.ini file if you have one. You can locate your php.ini file by running the following at the command line:
php --ini12.) Next, edit your php.ini file with the path you learned using the program above, for example:
vi /usr/local/lib/php.ini13.) Find the value date.timezone and replace the value inside the quotation marks with <Step 4 Directory>/<Step 6 Filename> just as you did with the /etc/sysconfig/clock file. Remember to press[Insert] to edit the file and when done, [ESC] and then :wq to write and quit vim.
14.) Restart Apache to have the changes take place (this may vary depending on how your system is setup:
service httpd restart15.) Run the date program again to check your changes were saved:
dateYou should now have the time zone abbreviation of the zone you updated your system to such as MST/MDT
There you have it, your server is now setup to the time zone you specified. Certain programs may have their own time zones settings which you will need to change but for most systems, this is all you need to do. If you need to update the time, check out our article, Synchronizing Your Server's Clock.
Rather Mean Servers do it for you? Not a problem, open a sales ticket with Mean Servers and we will ensure your time is synchronized and that the time zone is set to your desired locale. Please note that a small client help fee will apply unless you are a Enterprise Managed customer.