Offset of a given timezone from GMT in linux shell script

dutch picture dutch · May 13, 2010 · Viewed 15.2k times · Source

Is there a way to get the offset of a given timezone (identifier like EDT or America/New_York) from GMT in linux shell script?

Answer

Missaka Wijekoon picture Missaka Wijekoon · May 13, 2010

Export your TZ environment variable and print date with %z for timezone offset.

#!/bin/sh
export TZ=":Pacific/Auckland"
date +%z