≡ Menu

How to find out zone information for given country on Linux or Unix

How do I find out the current time for each zone name specified on the command line on a Linux, FreeBSD, OS X or Unix-like system? How do I report time zone information for Singapore or Japan on the command line?

You can use the zdump command to see the current time for each zone name specified on the command line.

How do I find a list of all zone name?

The standard time zone directory is located at the following location:

  1. AIX, Solaris, HP-UX – /usr/share/lib/zoneinfo/
  2. OS X, FreeBSD, OpenBSD, NetBSD – /usr/share/zoneinfo/
  3. Linux – /usr/share/zoneinfo/

Cd to above directory to see a time zone database file:
$ cd /usr/share/zoneinfo/
$ ls -l
$ ls -l | more
$ ls

Sample outputs:

+VERSION	Australia	EET		Factory		Greenwich	Jamaica		Mexico		Poland		US		posixrules
Africa		Brazil		EST		GB		HST		Japan		NZ		Portugal	UTC		zone.tab
America		CET		EST5EDT		GB-Eire		Hongkong	Kwajalein	NZ-CHAT		ROC		Universal
Antarctica	CST6CDT		Egypt		GMT		Iceland		Libya		Navajo		ROK		W-SU
Arctic		Canada		Eire		GMT+0		Indian		MET		PRC		Singapore	WET
Asia		Chile		Etc		GMT-0		Iran		MST		PST8PDT		Turkey		Zulu
Atlantic	Cuba		Europe		GMT0		Israel		MST7MDT		Pacific		UCT		iso3166.tab

You can cd into directory such as Asia, Europe, or America to get more detailed information:
$ cd America
$ ls

Sample outputs:

Adak		Blanc-Sablon	Cordoba		Fort_Nelson	Indiana		Maceio		Montevideo	Port_of_Spain	Sao_Paulo	Toronto
Anchorage	Boa_Vista	Costa_Rica	Fort_Wayne	Indianapolis	Managua		Montreal	Porto_Acre	Scoresbysund	Tortola
Anguilla	Bogota		Creston		Fortaleza	Inuvik		Manaus		Montserrat	Porto_Velho	Shiprock	Vancouver
Antigua		Boise		Cuiaba		Glace_Bay	Iqaluit		Marigot		Nassau		Puerto_Rico	Sitka		Virgin
Araguaina	Buenos_Aires	Curacao		Godthab		Jamaica		Martinique	New_York	Rainy_River	St_Barthelemy	Whitehorse
Argentina	Cambridge_Bay	Danmarkshavn	Goose_Bay	Jujuy		Matamoros	Nipigon		Rankin_Inlet	St_Johns	Winnipeg
Aruba		Campo_Grande	Dawson		Grand_Turk	Juneau		Mazatlan	Nome		Recife		St_Kitts	Yakutat
Asuncion	Cancun		Dawson_Creek	Grenada		Kentucky	Mendoza		Noronha		Regina		St_Lucia	Yellowknife
Atikokan	Caracas		Denver		Guadeloupe	Knox_IN		Menominee	North_Dakota	Resolute	St_Thomas
Atka		Catamarca	Detroit		Guatemala	Kralendijk	Merida		Ojinaga		Rio_Branco	St_Vincent
Bahia		Cayenne		Dominica	Guayaquil	La_Paz		Metlakatla	Panama		Rosario		Swift_Current
Bahia_Banderas	Cayman		Edmonton	Guyana		Lima		Mexico_City	Pangnirtung	Santa_Isabel	Tegucigalpa
Barbados	Chicago		Eirunepe	Halifax		Los_Angeles	Miquelon	Paramaribo	Santarem	Thule
Belem		Chihuahua	El_Salvador	Havana		Louisville	Moncton		Phoenix		Santiago	Thunder_Bay
Belize		Coral_Harbour	Ensenada	Hermosillo	Lower_Princes	Monterrey	Port-au-Prince	Santo_Domingo	Tijuana

How do I see time zone information for given country/zone name?

To see time zone information for Singapore , enter:
$ zdump Singapore
To see time zone information for Japan, enter:
$ zdump Japan
To see time zone information for Iceland, enter:
$ zdump Iceland
To see time zone information for Perth (AU), enter:
$ zdump Australia/Perth
To see time zone information for India, enter:
$ zdump Asia/Kolkata
To see time zone information for New York , enter:
$ zdump America/New_York
Sample outputs:

Fig.01: zdump Linux and Unix command in action

Fig.01: zdump Linux and Unix command in action

How to use bash for loop to see current time in different zones?

Say your cloud server located in 4 different time zone and you want to know the current time for techsupport purpose:

for t in America/New_York Australia/Perth Japan Asia/Kolkata ; do   zdump $t; done

Sample outputs:

America/New_York  Wed Dec 30 12:03:23 2015 EST
Australia/Perth  Thu Dec 31 01:03:23 2015 AWST
Japan  Thu Dec 31 02:03:23 2015 JST
Asia/Kolkata  Wed Dec 30 22:33:23 2015 IST

Be verbose

You can pass the -v option to zdump command. From the man page:

For each zonename on the command line, print the time at the lowest possible time value, the time one day after the lowest possible time value, the times both one second before and exactly at each detected time discontinuity, the time at one day less than the highest possible time value, and the time at the highest possible time value, Each line ends with isdst=1 if the given time is Daylight Saving Time or isdst=0 otherwise.

Try the following command:
$ zdump -v Japan
Sample outputs:

Japan  Fri Dec 13 20:45:52 1901 UTC = Sat Dec 14 05:45:52 1901 JCST isdst=0
Japan  Sat Dec 14 20:45:52 1901 UTC = Sun Dec 15 05:45:52 1901 JCST isdst=0
Japan  Thu Sep 30 14:59:59 1937 UTC = Thu Sep 30 23:59:59 1937 JCST isdst=0
Japan  Thu Sep 30 15:00:00 1937 UTC = Fri Oct  1 00:00:00 1937 JST isdst=0
Japan  Sat May  1 16:59:59 1948 UTC = Sun May  2 01:59:59 1948 JST isdst=0
Japan  Sat May  1 17:00:00 1948 UTC = Sun May  2 03:00:00 1948 JDT isdst=1
Japan  Fri Sep 10 15:59:59 1948 UTC = Sat Sep 11 01:59:59 1948 JDT isdst=1
Japan  Fri Sep 10 16:00:00 1948 UTC = Sat Sep 11 01:00:00 1948 JST isdst=0
Japan  Sat Apr  2 16:59:59 1949 UTC = Sun Apr  3 01:59:59 1949 JST isdst=0
Japan  Sat Apr  2 17:00:00 1949 UTC = Sun Apr  3 03:00:00 1949 JDT isdst=1
Japan  Fri Sep  9 15:59:59 1949 UTC = Sat Sep 10 01:59:59 1949 JDT isdst=1
Japan  Fri Sep  9 16:00:00 1949 UTC = Sat Sep 10 01:00:00 1949 JST isdst=0
Japan  Sat May  6 16:59:59 1950 UTC = Sun May  7 01:59:59 1950 JST isdst=0
Japan  Sat May  6 17:00:00 1950 UTC = Sun May  7 03:00:00 1950 JDT isdst=1
Japan  Fri Sep  8 15:59:59 1950 UTC = Sat Sep  9 01:59:59 1950 JDT isdst=1
Japan  Fri Sep  8 16:00:00 1950 UTC = Sat Sep  9 01:00:00 1950 JST isdst=0
Japan  Sat May  5 16:59:59 1951 UTC = Sun May  6 01:59:59 1951 JST isdst=0
Japan  Sat May  5 17:00:00 1951 UTC = Sun May  6 03:00:00 1951 JDT isdst=1
Japan  Fri Sep  7 15:59:59 1951 UTC = Sat Sep  8 01:59:59 1951 JDT isdst=1
Japan  Fri Sep  7 16:00:00 1951 UTC = Sat Sep  8 01:00:00 1951 JST isdst=0
Japan  Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 12:14:07 2038 JST isdst=0
Japan  Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 12:14:07 2038 JST isdst=0

How to cut off the verbose output

You can also pass the -c cutoffyear option to cut off the verbose output near the start of the given year. For example, to see verbose time zone information for Japan with verbose output stopping near the start of the year 2035, enter:
$ zdump -v -c 2035 Japan

Share this tutorial on:

{ 0 comments… add one }

Leave a Comment


   Tagged with: , , , ,