The immediate next step is to set the date and time of the server to suit
your business needs. Since your server is most likely far away from your administrative
location, you will need to choose a time zone for your server so that the time display
on your web site matches what you see on your local computer.
This can be accomplished easily with the Linux command date
. To see the current
server date and time, use the command date
with no arguments. The following example
shows the server date and time in US Mountain Standard Time zone (MST).
[firstname.lastname@example.org ~]# date
Sun Oct 19 05:53:09 MST 2008
If no time adjustment is needed, you can skip the rest of this section.
The option -s of the command date sets the new server's time and date based upon a
text string of specified date and time. The hour and minute adjustment to your local
time preference can be specified immediately after the time setting (-07:00 in the
[email@example.com ~]# setdate -s "2008-10-19 05:53:09-07:00"
Time zone adjustment
. If you plan to display the server's time on your web site
with a preferred time zone, you might want to make adjustment to the time zone setting.
If you are a first-time Linux user and have never worked in a shell environment,
or are not familiar with Linux file system, you can just skip the following section
and come back when you become more proficient with Linux shell commands and text editing tools.
The time zone information for the local time is stored in the configuration file /etc/sysconfig/clock
Modifying the line with the keyword ZONE= in the file with the appropriate zone (for example, Mexico City
corresponds to the US Central Standard Time zone (CST).
The Earth is divided into time zones that are 15 degrees of longitude each, since this corresponds
to the amount of angular distance the Sun travels in one hour. 0-degree longitude runs through the
Royal Observatory in Greenwich, England. This is the origin of Greenwich Mean Time, or GMT. For all
practical purposes, GMT and UTC are identical.
Time zone is a complex issue since some countries observe Daylight Savings Time (DST), while others
do not. Even within some countries, some states or districts do not observe DST while the rest of
the country does. DST can also begin and end on different days in different countries.
To fully support time zones with DST, Linux stores the required time zone rules for various known
geographical locations in the directory /usr/share/zoneinfo
. These are binary files and
cannot be edited easily with a regular text editor. These files allow Linux to convert UTC time
into appropriate local dates and times.