Tyler Fullerton wrote:
>
> If I have the following script: www.somewhere.com/e3/datetz.cgi (where
> e3 is using PerlRun) that does the following:
>
> $ENV{'TZ'} = 'US/Eastern';
> POSIX::tzset();
> my @time = localtime();
> my $time = time();
> $ENV{'TZ'} = 'US/Pacific';
> POSIX::tzset();
>
> # I would expect this to print current time info in the Eastern
> # time zone.
> print "$_\n" foreach @time;
> print "$time\n";
>
> At this point I would expect the values returned in @time and $time to
> be in the Eastern timezone. This works no problem in a non-mod_perl'd
> environment but not under mod_perl.
This works fine for me. I tested under vanilla CGI, Apache::PerlRun, and
Apache::Registry.
> Would it be beneficial to put code in a PerlFixUpHandler that sets the
> time zone data?
I doubt it. If setting the time zone RIGHT before running localtime
doesn't help, I don't think setting it long before will.
The only thing I can think of that might be causing this is if
PerlTaintCheck is turned on in the mod_perl, and it doesn't like
something about the environment being monkeyed with.
What's the output when you run this?
#!/usr/bin/env perl
use strict;
use warnings;
use POSIX qw(tzset);
$ENV{'TZ'} = 'US/Eastern';
POSIX::tzset();
my $eastern = localtime();
$ENV{'TZ'} = 'US/Pacific';
POSIX::tzset();
my $pacific = localtime();
print "Content-type: text/plain\n\n",
"Eastern: $eastern\n",
"Pacific: $pacific\n";
Regards,
Philip