Assume that your current timezone is UTC. You would like to change your server’s timezone to Pacific Time. How do I change the timezone on my Linux distribution? On some distributions (for example, CentOS), the timezone is controlled by /etc/localtime file. The /etc/localtime file is a link to or copy of a file containing information about your time zone.
You need to use the following syntax to print current date and time on screen:
The date syntax has many options; you can use formatting options with spaces and commas to make the date look nice like “Friday, February 14, 2014, 00:00:00 AM” get by using the date command:
date +"%A, %B %d, %Y, %T %p"
If the syntax above shows the wrong time or date, normally is because the system is set to the wrong timezone.
TimeZone information files are usually in /usr/share/zoneinfo but this depends on your distribution. there are now about a dozen distributions out there (Debian, Dedora, Ubuntu, Mageia, Min Linux, Fuduntu, Red Har, Backtrack, Arch). So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it. For example, all US timezones are located under under the /usr/share/zoneinfo/US directory as shown below.
For other country timezones, browse the /usr/share/zoneinfo directory.
First step: delete the current localtime file /etc/localtime.
Link the Los_Angeles file from the above the U.S. directory to the /etc/localtime directory as shown below.
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Now the timezone on your Linux system is changed to the U.S. Los Angeles time. You can use the “date” command to verify.
To show the current timezone in the file /etc/timezone, use the command:
To change this to the U.S. Los Angeles time, we need to modify the /etc/timezone file. First step: edit the /etc/timezone file via vim or nano. Vi editor:
Second step: modify the file as shown below:
set the timezone from the terminal using the TZ variable.