21

What command(s) can I use to examine the contents of the timezone files, such as /etc/localtime or the files under /usr/share/zoneinfo/*?

  • 2
    apropos -s 1 -a time zone – Gilles Aug 8 '13 at 22:34
27

The most appropriate command would appear to be zdump.

$ zdump /etc/localtime 
/etc/localtime  Wed Aug  7 23:52:25 2013 EDT

$ zdump /usr/share/zoneinfo/* | tail -10
/usr/share/zoneinfo/Singapore    Thu Aug  8 11:52:48 2013 SGT
/usr/share/zoneinfo/Turkey       Thu Aug  8 06:52:48 2013 EEST
/usr/share/zoneinfo/UCT          Thu Aug  8 03:52:48 2013 UCT
/usr/share/zoneinfo/Universal    Thu Aug  8 03:52:48 2013 UTC
/usr/share/zoneinfo/US           Thu Aug  8 03:52:48 2013
/usr/share/zoneinfo/UTC          Thu Aug  8 03:52:48 2013 UTC
/usr/share/zoneinfo/WET          Thu Aug  8 04:52:48 2013 WEST
/usr/share/zoneinfo/W-SU         Thu Aug  8 07:52:48 2013 MSK
/usr/share/zoneinfo/zone.tab     Thu Aug  8 03:52:48 2013
/usr/share/zoneinfo/Zulu         Thu Aug  8 03:52:48 2013 UTC

You can also interrogate these files using the file command:

$ file /etc/localtime 
/etc/localtime: timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 235 transition times, 4 abbreviation chars

$ file /usr/share/zoneinfo/Singapore
/usr/share/zoneinfo/Singapore: timezone data, version 2, 8 gmt time flags, 8 std time flags, no leap seconds, 8 transition times, 8 abbreviation chars
0

Try tzdump. I found it here: http://www.cise.ufl.edu/~seeger/dist/tzdump.c It is a C program and so will need to be compiled.

  • That program includes tzfile.h which does not appear to be available. There is a github copy of the same program which also lacks tzfile.h. – wallyk Sep 17 '15 at 3:10
0

Steps:

  1. First check the localtime of the docker container:

    [root@locdb oracle]# zdump /etc/localtime
    /etc/localtime  Tue May 22 13:59:40 2018 UTC
    
  2. Check the timezones like below:

    [root@locdb oracle]# zdump /usr/share/zoneinfo/* | tail -10
    /usr/share/zoneinfo/UTC          Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/Universal    Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/W-SU         Tue May 22 17:01:21 2018 MSK
    /usr/share/zoneinfo/WET          Tue May 22 15:01:21 2018 WEST
    /usr/share/zoneinfo/Zulu         Tue May 22 14:01:21 2018 UTC
    /usr/share/zoneinfo/iso3166.tab  Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/posix        Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/posixrules   Tue May 22 10:01:21 2018 EDT
    /usr/share/zoneinfo/right        Tue May 22 14:01:21 2018
    /usr/share/zoneinfo/zone.tab     Tue May 22 14:01:21 2018
    
  3. Copy the one that you need for example :

    cp  /usr/share/zoneinfo/UTC /etc/localtime
    
  • correcting the command in step 2: zdump /usr/share/zoneinfo/* | tail -10 – Shantonav Sen May 22 '18 at 12:03
  • I think mentioning docker here is a distraction from the general solution. – Jeff Schaller May 22 '18 at 13:02
  • I also don't yet see how this is different from slm's answer – Jeff Schaller May 22 '18 at 13:03
  • you are right @Jeff I was trying out this solution inside a docker container without impacting the hos hence a probable mixup. – Shantonav Sen May 23 '18 at 8:40
-5

Actually, anything may be examined by strings:

# strings /etc/localtime
  • 4
    Yeah that doesn't really work. Try it. It gives a lot of garbage and you can't really make out the contents of the locale. – slm Aug 8 '13 at 5:05
  • Might as well suggest using a hexeditor. – jgmjgm Feb 13 '17 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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