Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

We are adding timezone support to our Ubuntu application.

The time zone info on my machine is in /usr/share/zoneinfo.

  1. Is it always in that directory? If so, where is that specified?
  2. If not, is there system call similar to "gettimeofday(2)" that I can make to find out where it is?

Thanks in advance.

share|improve this question
up vote 2 down vote accepted

The search location for the time zones is encoded in the C library (where the various time zone aware functions are found):

$ strings -a /lib/x86_64-linux-gnu/ | grep zoneinfo

The C library code makes use of this directory as a preprocessor #define, so there is no routine to ask what value it was compiled with.

If you need to parse the the time zone data yourself (as opposed to using the few C library routines available), then hard coding /usr/share/zoneinfo should be fine: if your target platforms follow the Linux File System Hierarchy, you should be safe.

If you are only interested in the local time zone, read /etc/localtime, which will be a copy of the relevant file from /usr/share/zoneinfo.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.