[erlang-questions] GMT difference with DST
Per Hedeland
per@REDACTED
Mon Dec 24 21:20:52 CET 2007
shahzad bhatti <bhatti_shahzad@REDACTED> wrote:
>
>I am looking for a built-in function to calculate difference between
>local time and UTC including any day light savings time. Can someone
>help with this. Thanks.
1> UTC = calendar:universal_time().
{{2007,12,24},{20,13,5}}
2> Local = calendar:universal_time_to_local_time(UTC).
{{2007,12,24},{21,13,5}}
3> Diff = calendar:datetime_to_gregorian_seconds(Local) - calendar:datetime_to_gregorian_seconds(UTC).
3600
Note that it isn't always possible to find the diff if you're
starting with a given local time - see the documentation for
local_time_to_universal_time_dst/1 in calendar(3).
--Per Hedeland
More information about the erlang-questions
mailing list