Timezone in date?

nitin_cherian picture nitin_cherian · Dec 9, 2010 · Viewed 28.5k times · Source

From where does the date command in Linux get the timezone information? I cannot see /etc/localtime file and /usr/share/zoneinfo directory in my system. Still when i execute the date command i get the following output

Thu Dec 9 16:28:18 UTC 2010

Kindly tell me from where does the command get the timezone information?

Thanks, LinuxPenseur

Answer

sarnold picture sarnold · Dec 9, 2010

Don't forget that UTC is how standard Unix systems store the date/time in the real time clock. You have to jump through hoops using funny programs (see the hwclock(8) manpage) if you dual-boot to Windows, which prefers the local time to be stored in the CMOS real time clock.

So the date(1) program is simply showing you the results of "I have no configured time zone":

# date -u
Thu Dec  9 10:40:54 UTC 2010
# TZ=UTC date
Thu Dec  9 10:40:57 UTC 2010
# TZ=PST8PDT date
Thu Dec  9 02:41:02 PST 2010
#