in reply to Re: Mod_Perl multiple timezones
in thread Mod_Perl multiple timezones
I realize that this thread is older than Perl itself, but it comes up very high in Google, so I thought I'd update.
The following works perfectly for me in Perl 5.10:
#!/usr/bin/perl use strict; use warnings; ### US Time Zones #my $time_zone = 'US/Alaska'; #my $time_zone = 'US/Aleutian'; #my $time_zone = 'US/Arizona'; #my $time_zone = 'US/Central'; my $time_zone = 'US/Eastern'; #my $time_zone = 'US/East-Indiana'; #my $time_zone = 'US/Hawaii'; #my $time_zone = 'US/Indiana-Starke'; #my $time_zone = 'US/Michigan'; #my $time_zone = 'US/Mountain'; #my $time_zone = 'US/Samoa'; #my $time_zone = 'US/Pacific'; ### set time zone for Perl to access with localtime ### can be any zone listed in /usr/share/zoneinfo and its subfolders $ENV{TZ} = $time_zone; print "System Time Zone from Perl is $ENV{TZ}\n"; my $timenow = localtime(time); print "Time from System is $timenow\n";
There was no need to use POSIX::tzset().
It works well from both the command line and from Apache2.
-Wes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mod_Perl multiple timezones
by jswalker (Initiate) on May 14, 2012 at 16:18 UTC |