date
command can achieve that with environment variable TZ
, but you need to use perfect match timezone string, which you can found at /usr/share/zoneinfo/posix
.I found an answer of having world clock using a simple Bash script, and I expanded it a little more, the Gist:
If run
cliclock.sh testzones cet
and testzones
file contains:US/Pacific Europe/Berlin Chile/Continental new york Los AngelesA snapshot of output looks like:
US/Pacific 2012-06-14 17:10:57 PDT Europe/Berlin 2012-06-15 02:10:57 CEST Chile/Continental 2012-06-14 20:10:57 CLT America/New_York 2012-06-14 20:10:57 EDT America/Los_Angeles 2012-06-14 17:10:57 PDT CET 2012-06-15 02:10:57 CESTThere are more to improve this script, such as options to add or to remove a zone. You can press Q to quit this script elegantly, so a few more lines should be enough to accept some additional zone since there is already a function for checking validity of input zone name. It can't recognize country codes, but it'd not be a huge task to add a group of zones associated to a country code.