Skip to content

Instantly share code, notes, and snippets.

@sbz
Created July 17, 2024 16:17
Show Gist options
  • Save sbz/62573bbbb224f4fa4b41778114762343 to your computer and use it in GitHub Desktop.
Save sbz/62573bbbb224f4fa4b41778114762343 to your computer and use it in GitHub Desktop.
wdate: worldwide timezone date
#!/bin/bash
# date --date='TZ="UTC+4" 2016-08-22 10:37:44' "+%Y-%m-%d %H:%M:%S"
# Show date and time in other time zones
search=$1
format='%a %F %T %z'
zoneinfo=/usr/share/zoneinfo
if command -v timedatectl >/dev/null; then
tzlist=$(timedatectl list-timezones)
else
# tzlist=$(find -L $zoneinfo -type f -printf "%P\n")
tzlist=$(find -L $zoneinfo -type f|rev|cut -d '/' -f 1,2|rev)
fi
grep -i "$search" <<< "$tzlist" \
| while read z
do
d=$(TZ="$z" gdate +"$format")
printf "%-32s %s\n" "$z" "$d"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment