Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to check which time zone I'm currently in on Linux?

share|improve this question

migrated from Jul 11 '11 at 7:33

This question came from our site for professional and enthusiast programmers.

up vote 12 down vote accepted

Usually, the TZ environment variable will tell you something useful. However, it is best to use functions such as mktime() and localtime() to convert between time_t and a local timezone representation. That is, don't try to do the conversion yourself.

share|improve this answer
is there any Command that tells about timezone the user is in? – Hussy Hussain Jul 11 '11 at 5:00
Sure, date will tell you. – Greg Hewgill Jul 11 '11 at 5:01
i have two instance of server , if i give "date" command in both server it shows different time. time zone for both server is IST, time of one server: Mon Jul 11 10:39:31 IST 2011 and other server Mon Jul 11 10:35:31 IST 2011 .. there is a difference of 4 minutes – Hussy Hussain Jul 11 '11 at 5:06
On Precise Pangolin echo $TZ returns nothing for me. – Iain Elder Oct 5 '13 at 19:48
And you believe you wrote an answer right? – abcKx Nov 18 '15 at 19:32

If you mean from the console, just type:

date +%Z
share|improve this answer
good, works well. – Silver Moon Nov 18 '13 at 7:18
this should be the accepted answer – KalenGi Mar 24 '14 at 10:04
good point... changed the answer to that effect – Rasman Jun 19 '14 at 15:44

If you want the numeric timezone:

date +'%:z %Z'

Sample output:

-05:00 EST
share|improve this answer
On OS X this outputs :z EST – suspectus Feb 13 '15 at 17:01
This if for linux. – Paul Vargas Feb 13 '15 at 17:18
More precisely, this applies to GNU date. The BusyBox version prints something non-sensical, "%:z CEST" in my case. – Léo Lam Jun 3 '15 at 18:42
However, date +%z works fine on OS X. I suggest you modify the answer. – Neil Mayhew Aug 14 '15 at 17:22
Hi, @NeilMayhew Thanks! Humm... but the question has the tags linux ubuntu-10.04 – Paul Vargas Aug 14 '15 at 17:29

I wanted to find the timezone in "US/Eastern" or "Europe/London" form instead. You can find this in:

  • /etc/timezone (present on Ubuntu and Red Hat? but not e.g. Amazon Linux)
  • (on Red Hat style systems) as ZONE="US/Eastern" in /etc/sysconfig/clock
  • or you can try and match /etc/localtime to one of the files under /usr/share/zoneinfo; annoyingly this doesn't seem to be a symlink, but you can e.g.

    cd /usr/share/zoneinfo
    find * -type f -exec sh -c "diff -q /etc/localtime '{}' > /dev/null && echo {}" \;

    to find matching files - there's probably better ways to do that, but that works. There will be multiple matches.

share|improve this answer
find /usr/share/zoneinfo/ -type f| xargs md5sum | grep $(md5sum /etc/localtime | cut -d' ' -f1) – freiheit Jul 4 at 18:25
$ strings /etc/localtime | tail -n 1

So I'm on Mountain Time. Although advices above on using environment variable or just date command output sometimes work better, depending how you want to use that.

share|improve this answer
  • /etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.
  • Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.
  • Type /sbin/hwclock --systohc [--utc] to set the hardware clock.

The Linux kernel always stores and calculates time as the number of seconds since midnight of the 1st of January 1970 UTC regardless of whether your hardware clock is stored as UTC or not. Conversions to your local time are done at run-time. One neat thing about this is that if someone is using your computer from a different timezone, they can set the TZ environment variable and all dates and times will appear correct for their timezone.

If the number of seconds since the 1st of January 1970 UTC is stored as an signed 32-bit integer (as it is on your Linux/Intel system), your clock will stop working sometime on the year 2038. Linux has no inherent Y2K problem, but it does have a year 2038 problem. Hopefully we'll all be running Linux on 64-bit systems by then. 64-bit integers will keep our clocks running quite well until aproximately the year 292271-million.

share|improve this answer

For ubuntu try this :

$ cat /etc/timezone

Sample output :


For other distro Reference :

share|improve this answer

You must log in to answer this question.