Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Mod_Perl multiple timezones

by dtr (Scribe)
on Jul 23, 2003 at 19:14 UTC ( [id://277302]=note: print w/replies, xml ) Need Help??


in reply to Re: Mod_Perl multiple timezones
in thread Mod_Perl multiple timezones

The following script will work beautifully when run from the command line.

When called as a CGI under mod_perl_2 (1.99.08) it will output identical dates for all the different time zones!

Is this a known problem???

#! /opt/perl/bin/perl -w

use strict;

use POSIX;

print
    "Content-type: text/plain\n\n",
    "Time zone stuff\n",
    "***************\n",
    "\n";

my $now = time;


$ENV{TZ} = "Europe/London"; POSIX::tzset();
print "Time in Europe/London is   " . localtime($now) . " +OK\n";


$ENV{TZ} = "Europe/Paris"; POSIX::tzset();
print "Time in Europe/Paris is    " . localtime($now) . " +OK\n";


$ENV{TZ} = "America/Chicago"; POSIX::tzset();
print "Time in America/Chicago is " . localtime($now) . " +OK\n";


exit;

Replies are listed 'Best First'.
Re: Re: Re: Mod_Perl multiple timezones
by Chmrr (Vicar) on Jul 23, 2003 at 23:18 UTC

    I'd guess this has something to do with the lack of any real environment to speak of under mod_perl. I will admit to only being familiar with mod_perl 1, however this does look like a bug of some sort (it works fine under mod_perl 1 using Apache::Registry and perl 5.6.1). To track it down, a few more specifics are needed.

    How do you have mod_perl set up (some bits of your apache config might be useful)? What version of perl is mod_perl using?

    PS -- You say that this is being called "as a CGI under mod_perl," which is a bit of an oxymoron -- either you run programs molasses-slow under CGI, or you're using the accelerated features of mod_perl. You can't be doing both -- from Apache's point of view, either you're going through mod_perl, or through mod_cgi.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

      Hi Chmrr, you seem to have the answers to all of my problems today! Here's the relevant sections of the httpd.conf file:-
      LoadModule perl_module modules/mod_perl.so
      
      PerlOptions +SetupEnv +ParseHeaders +Parent -GlobalRequest
      PerlSwitches -w -T
      PerlRequire  "/var/www/startup.pl"
      
      Alias /test  /var/www/test
      
      <Directory /var/www/test>
          Options +ExecCGI
          Order allow,deny
          Allow from all
      </Directory>
      
      <Location /test/*.pl>
          SetHandler perl-script
          PerlResponseHandler ModPerl::Registry
      </Location>
      
      
      I've tried this with +Parent and -Parent (I'm trying to support multiple vhosts on this server), and also with +SetupEnv and -SetupEnv.
        Try setting TZ in the shell before starting Apache:

        TZ=<some time zone>; export TZ

        I was having the exact same problem and explicitly setting it cured the problem. Perhaps there's a bug with setting a value for a previously non-existent environmental variable.

        StarMan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-12-09 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (53 votes). Check out past polls.