In Perl, I\'d like to look up the localtime in a specific timezone. I had been using this technique:
$ENV{TZ} = \'America/Los_Angeles\';
my $now = scalar loc
Use POSIX::tzset.
use POSIX qw(tzset);
my $was = localtime;
print "It was $was\n";
$ENV{TZ} = 'America/Los_Angeles';
$was = localtime;
print "It is still $was\n";
tzset;
my $now = localtime;
print "It is now $now\n";
$ perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. $ perl tzset-test.pl It was Wed Apr 15 15:58:10 2009 It is still Wed Apr 15 15:58:10 2009 It is now Wed Apr 15 12:58:10 2009