Hi!
It is easy to get the time offset to GMT from current date
using time to GMT
. But is there a way to get the time offset from GMT for any local date/time that is NOT the current (given the time zone set in System preferences)?
The problem I need to solve is that my the script I’m working on needs to know the time offset for varying date-times before and ahead of the point in time when the script is run, and that he time offset might vary depending on if daylight time saving is present or not at that point in time.
So I would like something that looks like this (where the results in the examples is the correct ones for “my” time zone, i.e. Stockholm, CET):
set theDateString to "2019-08-01 14:01:24"
set timeOffset to timeToGMT(date theDateString)
--> 7200
set theDateString to "2019-12-01 14:01:24"
set timeOffset to timeToGMT(date theDateString)
--> 3600