AsianFlu has asked for the wisdom of the Perl Monks concerning the following question:

In perl 5.6.0, on redhat 7, I used to do something like this:
$ENV{TZ}="US/Eastern"; # use locatime(time) to get the time $ENV{TZ}="Other/Zone"; # use localtime(time) to get the time # subtract the difference
This doesn't work anymore on perl 5.8.0 on redhat 9. Although perl will start and localtime() obeys the current setting of TZ, using ENV{TZ} to change it, does nothing! so now I have to use this terrible thing:
my $rfc_offset = `TZ=US/Eastern; date +%s`; my $rfc_offset2= `TZ=Other/Zone; date +%s`; # code to work out difference in seconds.
Which is highly upsetting! I do not want to load the huge Date::Time module in just do so such a simple thing. (current seconds difference between two time zones). What shall I do? I've tried POSIX strftime as well, and that doesnt help anymore either. Why was this (apparently) changed? or is it a bug?

Replies are listed 'Best First'.
Re: Offset between two time zones.
by sgifford (Prior) on Oct 24, 2003 at 23:15 UTC
    I'm not sure there's a portable way to do what you want, apart from Time::Date or similar, or compiling a database of timezones and offsets and using that.

    That said, on my system zdump(8) looks helpful:

    sgifford@sglaptop sgifford$ /usr/sbin/zdump US/Michigan Zulu
    US/Michigan  Fri Oct 24 03:16:56 2003 EDT
    Zulu         Fri Oct 24 07:16:56 2003 UTC
    
Re: Offset between two time zones.
by tachyon (Chancellor) on Oct 25, 2003 at 10:53 UTC

    I know the internal handling of timezones changed significantly between RH6 and RH7.3 (Can't remember which version precisely). We always set server time to GMT (UTC) and have the offsets in a config file for apps where it matters.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print