in reply to Re: Converting local time to UTC mystery
in thread Converting local time to UTC mystery

This hard-codes the timezone (+0200). I happen to know that it is two hours off, but in general, the program can run in any local timezone, so I would need to find out how much I am away from UTC.

In addition, I would strongly prefer a solution which does not involve DateTime. In my case, parsing the string is easy enought that it can be done by HTTP::Date, so the only problem left is the timezone issue. So, is there an easy way to find out the time difference? Somehow Perl must already "know" this (otherwise, it would not be able to implement gmtime and localtime correctly, doesn't it?)

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Converting local time to UTC mystery
by ikegami (Patriarch) on Sep 05, 2011 at 16:26 UTC

    I would need to find out how much I am away from UTC.

    ...which changes during the year, making it that much more difficult. Yeah, hardcoding offsets is not the way to go.

      That said, '+0200' can be replaced with 'local'
        Indeed this works, thanks a lot!!! I wonder, where this is documented...

        For completeness, here the working function call:

        my $seconds_since_epoch=str2time($timestamp_local, 'local');

        -- 
        Ronald Fischer <ynnor@mm.st>
Re^3: Converting local time to UTC mystery
by Anonymous Monk on Sep 05, 2011 at 14:08 UTC