World time from the terminal

world-time-zones

What’s your favourite way to look up the time in a different timezone? For many of us it’s a google search. Did you know that you can look it up easily from the command line too? The Linux utility tzselect makes it possible.

Without further ado, here’s how you can look up the time at Paris:

$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
 1) Africa
 2) Americas
 3) Antarctica
 4) Asia
 5) Atlantic Ocean
 6) Australia
 7) Europe
 8) Indian Ocean
 9) Pacific Ocean
10) coord - I want to use geographical coordinates.
11) TZ - I want to specify the time zone using the Posix TZ format.
#? 7
Please select a country whose clocks agree with yours.
 1) Åland Islands     18) Greece            35) Norway
 2) Albania       19) Guernsey          36) Poland
 3) Andorra       20) Hungary           37) Portugal
 4) Austria       21) Ireland           38) Romania
 5) Belarus       22) Isle of Man       39) Russia
 6) Belgium       23) Italy         40) San Marino
 7) Bosnia & Herzegovina  24) Jersey            41) Serbia
 8) Britain (UK)      25) Latvia            42) Slovakia
 9) Bulgaria          26) Liechtenstein     43) Slovenia
10) Croatia       27) Lithuania         44) Spain
11) Czech Republic    28) Luxembourg        45) Svalbard & Jan Mayen
12) Denmark       29) Macedonia         46) Sweden
13) Estonia       30) Malta         47) Switzerland
14) Finland       31) Moldova           48) Turkey
15) France        32) Monaco            49) Ukraine
16) Germany       33) Montenegro        50) Vatican City
17) Gibraltar         34) Netherlands
#? 15

The following information has been given:

    France

Therefore TZ='Europe/Paris' will be used.
Local time is now:  Fri Jun 17 18:50:39 CEST 2016.
Universal Time is now:  Fri Jun 17 16:50:39 UTC 2016.
Is the above information OK?
1) Yes
2) No
#? ^C⏎ 

Now, a little more on tzselect. It doesn’t take any parameters and you can quit any time using Ctrl-c. As you an see above, the program is highly interactive and menu driven, making it very simple to use. Also, it doesn’t set the timezone of your system.

The timezone string from tzselect can be used as a param to date, though using the former is simpler as you don’t need to memorize anything.

$ TZ='Europe/Paris';date
Fri Jun 17 18:54:09 CEST 2016

However, if you just need to check the UTC time, date is handy:

$ date -u
Fri Jun 17 16:55:11 UTC 2016

2 thoughts on “World time from the terminal”

Leave a Reply

Your email address will not be published. Required fields are marked *