blahblahblah has asked for the wisdom of the Perl Monks concerning the following question:
I recently had to add some code that sets $ENV{TZ} to the correct local time. (Date::Manip requires this, and it wasn't already in my ENV on windows.) I've noticed that since doing that, when I call one perl script from another the localtime incorrectly returns GMT in the called script.
The result is:$ENV{'TZ'} = '-0400'; # also tried 'US/Eastern' with same result. print qq{---- $ENV{'COUNT'} ---- TZ: $ENV{'TZ'} localtime: } . scalar(localtime) . "\n"; $ENV{'COUNT'}++; exit if $ENV{'COUNT'} > 3; system("C:\\perl\\bin\\perl.exe C:\\cgi\\test");
I'm using ActiveState 5.8.8. When I try the same on Solaris with 5.8.1 it always shows the correct local time. I tried the following code after setting ENV{TZ}, but it had no effect on the result:C:\FootPrints1\cgi>C:\perl\bin\perl.exe C:\cgi\test ---- ---- TZ: -0400 localtime: Thu Sep 6 10:46:07 2007 ---- 1 ---- TZ: -0400 localtime: Thu Sep 6 14:46:07 2007 ---- 2 ---- TZ: -0400 localtime: Thu Sep 6 14:46:07 2007 ---- 3 ---- TZ: -0400 localtime: Thu Sep 6 14:46:07 2007
Any ideas how I can make localtime give me the local time (while still setting ENV{TZ} to keep Date::Manip happy)? What settings does localtime depend on?use POSIX(); POSIX::tzset();
Thanks, Joe
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: ENV{TZ} and localtime? (inconsistent time in child script)
by ikegami (Patriarch) on Sep 06, 2007 at 16:54 UTC | |
by blahblahblah (Priest) on Sep 07, 2007 at 00:30 UTC | |
Re: ENV{TZ} and localtime? (inconsistent time in child script)
by gam3 (Curate) on Sep 06, 2007 at 15:51 UTC |
Back to
Seekers of Perl Wisdom