Skip to content

Instantly share code, notes, and snippets.

Last active August 31, 2021 15:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save craigforr/d2c6fbee1e5c2a6f8bf82ea00cdaac96 to your computer and use it in GitHub Desktop.
BASH Script to display dates and times for any world time zone
# Show date and time in other time zones
# Source: python - command-line world clock? - Stack Overflow
function world_date(){
if [ "$1"x != 'x' ]; then
echo "Please provide a time zone."
format='%a %F %T'
find -L $zoneinfo -type f \
| grep -i "$search" \
| while read z; do
d=$(TZ=$z date +"$format")
printf "%-34s %23s\n" ${z#$zoneinfo} "$d"
world_date $1
Copy link

This works nicely in BASH on Ubuntu on Windows Subsystem for Linux (WSL) on Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment