September 24, 2022

Display the time of any time zone in your terminal without connecting to the internet

To get the current time in a time zone run:

$ TZ=<tzdata> date

For example:

$ TZ=America/New_York date

or

$ TZ=Asia/Istanbul date

If you need to look up the same time often, in your terminal, you can use CRTL + R to retrieve a command in your history. For example: type CRTL + R and then start typing TZ= etc.; your last timezone query should show.

You can also assign an alias.

You can find a list of all tzdata by running:

$ tzselect

You should see:

Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa                                7) Europe
2) Americas                              8) Indian Ocean
3) Antarctica                                9) Pacific Ocean
4) Asia                                 10) coord - I want to use geographical coordinates.
5) Atlantic Ocean                           11) TZ - I want to specify the timezone using the Posix TZ format.
6) Australia
#?

command-line interface (cli) personal computing gnu linux trisquel

No affiliates, No (Google) Analytics. © 2016-2023 yctct.com. Content is licensed under CC BY-NC-SA 4.0 .