Just a dumb trick I whipped up and was inordinately proud of. Sure I could go along to timeanddate dot com but I spend a lot of my time in my terminal and this is immediate. Small effort big payback.
OK, so the code is just this, added to .bashrc
tztime() {
for tz_name in "$@"; do
printf " In %-15s its %s\n" "$tz_name" "$(TZ=$tz_name date +'%H:%M:%S %Z')"
done
}
alias teamtime='tztime America/Chicago UTC Europe/London Asia/Manila Asia/Tokyo'
The first block is the function that does all the work, formatting the dates nicely.
for tz_name in "$@"; doloops over all arguments supplied as space-separated array.TZ=$tz_namesets thedate +'%H:%M:%S %ZTZenvironment variable and then runs date with the specified format. (TZ in your shell remains unchanged)%-15sprints the time-zone name left-aligned in a field at least 15 characters wide. This was just to get them to align nicely
The alias is whatever you want to call it, and is basically a space separated list of timezones you want to look at. Edit away. Output:
teamtime
In America/Chicago its 22:03:13 CDT
In UTC its 03:03:13 UTC
In Europe/London its 03:03:13 GMT
In Asia/Manila its 11:03:13 PST
In Asia/Tokyo its 12:03:13 JST