Skip to content

Instantly share code, notes, and snippets.

@valmat
Created October 2, 2019 11:07
Show Gist options
  • Save valmat/20d91e575a3c908b352aeb4084a4d45a to your computer and use it in GitHub Desktop.
Save valmat/20d91e575a3c908b352aeb4084a4d45a to your computer and use it in GitHub Desktop.
Get all time zones and their offsets in Linux.
#!/bin/bash
for tz in $(timedatectl list-timezones | grep -v 'UTC')
do
gmtoff=$(zdump -v "$tz" | grep 'gmtoff' | tail -n1 | grep -oE "[^ ]+$")
tz_offset="${gmtoff:7}"
if [[ "${gmtoff:0:7}" == "gmtoff=" ]]; then
echo "$tz;$tz_offset"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment