Created
July 17, 2024 16:17
-
-
Save sbz/62573bbbb224f4fa4b41778114762343 to your computer and use it in GitHub Desktop.
wdate: worldwide timezone date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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