Not all systems are synchronized to the time zone that you live in. In fact, if you rent a server like I do, it may be in an entirely different country.
CentOS has several commands concerning timezones. I don’t find some of them to be overly intuitive and figured that I would outline some easy-use recipes here:
1. Finding your system-wide timezone
The best documented way I’ve found to do this is with the following commands:
You will get output like the following:
/etc/localtime Sat Jul 5 16:42:53 2008 PDT
Which shows us that the local system-wide time zone for the server itself is “Pacific Daylight Time”.
Because we can set the time zone for our account; using the
date command reveals the current time, but the wrong time zone:
# date Sat Jul 5 19:42:53 EDT 2008
2. Setting your system-wide time zone
Setting the system-wide time zone can be achieved two ways.
One, you can copy the time zone file from
Two, you can run the
system-config-date program and choose the timezone tab. This is by far, the easiest way.
3. Setting your account time zone
Setting the account time zone is achieved by setting the TZ variable to the appropriate variable.
In Bourne Shell or BASH:
In C-Shell or TCSH:
setenv TZ "EST5EDT"
To find out what the variable should be set to, look for the appropriate file name in
/usr/share/zoneinfo or you can run the
4. Finding your account time zone
As noted before, running the date command shows the time zone for your environment: