[erlang-questions] Time zone

Ulf Wiger ulf@REDACTED
Mon Dec 11 13:14:12 CET 2006


> Hi,
>
> Is there a way to get the time zone configured on a machine without
> resorting to hacks.
>
> It'll be nice to have something like:
>
> calendar:time_zone().
> OR
> erlang:system_info(time_zone).

On a unix system, you can do this today:

11> os:getenv("TZ").
"MET"
13> time().
{13,11,13}
15> os:putenv("TZ","UWT+5").
true
16> time().
{7,11,58}

... you get the idea.

http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

for more info on the TZ variable.

Timezone handling is really tricky. We never could come up with a better
solution than setting the TZ variable directly in the VM environment.

BR,
Ulf W






More information about the erlang-questions mailing list