I recently learned how to change the timezone returned by localtime
in Perl.
use POSIX qw(tzset);
print localtime . "\n";
$ENV{TZ} = 'America/Los_Angeles';
print localtime . "\n";
tzset;
print localtime . "\n";
Outputs
Wed Apr 15 15:58:10 2009
Wed Apr 15 15:58:10 2009
Wed Apr 15 12:58:10 2009
Notice how the hour only changes after calling tzset
.
This is perl, v5.8.8 built for x86_64-linux-thread-multi
However, on my systems I'm getting,
Fri Jul 8 19:00:51 2016
Fri Jul 8 16:00:51 2016
Fri Jul 8 16:00:51 2016
Notice how on my system, the hour changes without calling tzset
. This holds true on recent versions of Perl in Ubuntu and Illumos, as well as Perl v5.8.8
on Solaris 10.
So if all my tests indicate that tzset
has no effect, why / what other systems require tzset
to be called explicitly? Do I still need to call tzset
to remain compatible with certain environments, or is it now a thing of the past?