in reply to why are timegm and timelocal returning the same epoch seconds values

Thank you for the responses. Here is more information. I do have "use Time::Local" at the top of my main script. My host is running Solaris 10 and the timezone is set for "US/Pacific". The file I am processing contains multiple(24) timestamps that are in GMT time and we have a customer who wants these times converted to local time.

  • Comment on Re: why are timegm and timelocal returning the same epoch seconds values

Replies are listed 'Best First'.
Re^2: why are timegm and timelocal returning the same epoch seconds values
by vsespb (Chaplain) on May 14, 2013 at 21:57 UTC

    1. Try extract this subroutine from you script and run it outside of your script.

    2. Is your TZ variable set?

    3. Try run with env TZ=US/Pacific

    4. Try run system tools (like 'date) which report time to make sure they recognize timezone correctly

Re^2: why are timegm and timelocal returning the same epoch seconds values
by karlgoethebier (Abbot) on May 15, 2013 at 10:55 UTC

    Update2:

    use DateTime; use DateTime::TimeZone; my $dt = DateTime->new( year => 2013, month => 4, day => 15, hour => 12, minute => 45, second => 47, time_zone => 'Europe/Berlin', ); my $tz = DateTime::TimeZone->new( name => 'US/Pacific' ); my $offset = $tz->offset_for_datetime($dt); print qq($offset\n); print DateTime::TimeZone->offset_as_string( $offset ) . qq(\n); print qq($dt->hour\n); $dt->set_time_zone( 'US/Pacific' ); print qq($dt->hour\n);

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»