Skip to content

Instantly share code, notes, and snippets.

@researcx
Created March 20, 2023 09:04
Show Gist options
  • Save researcx/b99e7b27b0d5b62d719f8a2d399c8b84 to your computer and use it in GitHub Desktop.
Save researcx/b99e7b27b0d5b62d719f8a2d399c8b84 to your computer and use it in GitHub Desktop.
multiple timezone date-time display
#!/bin/bash
# example:
#  sh ./datetime.sh
#  Monday 2023/03/20 09:01 UTC (GMT: 09:01 +0000 PDT: 02:01 -0700 CET: 10:01 +0100 UTC: 09:01 +0000)
timeZones=("Europe/London America/Vancouver Europe/Zurich Finland/Helsinki")
dateTime=$(date +"%A %Y/%m/%d %H:%M %Z")
get_timezone(){
dateTimeZoneGet=`echo -n $dateTimeZoneGet; TZ=":$1" date +" %Z: %H:%M %z"`
}
for timezone in ${timeZones[@]}; do
get_timezone $timezone
done
echo "$dateTime ($dateTimeZoneGet)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment