in reply to Time::CTime::strftime won't print Timezones...

This relies on the 'TZ' environment variable being set. Type 'set' at a shell prompt, and you'll find that TZ isn't defined.

Type 'export TZ=EST5' at a *nix shell prompt, or 'set TZ=EST5' under Windows, and then run your program (from the shell, so that the environment is inherited). It will then print the 'EST' portion of the TZ variable.

I'd like to tell you how to set it automatically, but I'm not sure I'd be giving accurate information. Maybe someone else can provide that piece of the (non-Perl) puzzle.

--Chris

e-mail jcwren
  • Comment on (jcwren) Re: Time::CTime::strftime won't print Timezones...

Replies are listed 'Best First'.
RE: (jcwren) Re: Time::CTime::strftime won't print Timezones...
by SamQi (Beadle) on Oct 11, 2000 at 00:09 UTC
    Well...this is meant to be a CGI...and I want it to determine at runtime what the timezone is... I could feasibly do it as such:
    $timezone = `date +%Z`;
    # blah...get all the information and plop it all into a string and print it
    

    And I might just end up doing that. :P

RE: (jcwren) Re: Time::CTime::strftime won't print Timezones...
by SamQi (Beadle) on Oct 11, 2000 at 06:50 UTC
    However...I like to stay away from backticks as much as I can. Any other ideas?
      The magic %ENV gives you access to environmental variables:
      use POSIX; $ENV{TZ} = 'KTZ'; # Kinakuta Time Zone print strftime('%l:%M:%S %p %Z, %A %B %o, %Y', localtime($time));
      Easy!
        Well...what I want to be able to do is write this script so that it is fairly hands-off as far as configuration. Basically, you put it in your cgi-bin and it runs...properly. I suppose for now that
        $ENV{TZ} = `date +%Z`;
        
        Will suffice.
        Thanks for the advice, guys!