How to get the hour difference between two time zones in bash
Bo Berglund
bo.berglund at gmail.com
Mon Mar 28 14:34:37 UTC 2022
I have a scriot that runs every day and it operates on data from both my
location and New York. It sets up at jobs at certain times in New York but doing
it from Stockholm.
I would like to automatically handle the time difference between the two sites
in the script.
The normal difference is 6 hours but for a couple of weeks in March it is 5
hours and in the fall it is 7 hours because the US and Sweden switches to/from
DST at different dates in March and October.
I just ran into the problem and could almost fix it by setting the TZ variable
in the script, but it only worked during the diff time and then it screwed up
again.
So I need to calculate on the start of the script which is the current number of
hours difference between Stockholm and New York.
How can this be done?
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list