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:
AIX, Solaris, HP-UX – /usr/share/lib/zoneinfo/
OS X, FreeBSD, OpenBSD, NetBSD – /usr/share/zoneinfo/
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
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
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