ReSpawn has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I need your help.
I wrote a cgi script that basically needs to transform UTC time to CEST time and vice versa. Using my basic skills and Google I came around with something like this to initialize my local timezone:
use Time::Local; use POSIX qw(tzset); $ENV{TZ} = 'Europe/Berlin'; tzset();
Reading a UTC timestamp from a database and transforming it to localtime works great when running the skript locally, but when called as a cgi from a browser, the same script fails in doing so and all dates are UTC.
Adding some debug code I found out that the tzset call does not seem to affect the system timezone. Here is the code:
($std, $dst) = POSIX::tzname(); system ("echo $std x $dst > /tmp/cgi.out"); system ("echo $ENV{TZ} >> /tmp/cgi.out");
The output reads "CET x CEST Europe/Berlin" when run locally and "UTC x Europe/Berlin" when run as cgi. Do you have any idea why this happens?
Additional info: perl 5.8.8 on AIX 6.1, Webspere Aplication Server 7x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strange localtime behaviour in cgi (Apache2)
by tye (Sage) on Apr 12, 2014 at 22:52 UTC | |
|
Re: strange localtime behaviour in cgi
by kschwab (Vicar) on Apr 11, 2014 at 15:43 UTC | |
|
Re: strange localtime behaviour in cgi
by locked_user sundialsvc4 (Abbot) on Apr 11, 2014 at 20:02 UTC |