LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2007, 10:29 AM   #1
estratos
Member
 
Registered: Jan 2006
Distribution: Ubuntu
Posts: 85

Rep: Reputation: 15
Local time and CGI's


Hi,

Running "localtime" (C code) in a standard application returns the local time depending on the time zone configured in /etc/TZ. This is working fine on my OpenSlug system so far. The problem comes when I run the same code in a cgi (fast cgi in fact) through the Lighttpd web server. Then "localtime" returns the current time in UTC format, forgetting the contents of the TZ file.

Any idea? I really need to display the local time in both the application and the cgi.

Thank you very much,

Daniel.
 
Old 10-10-2007, 07:51 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
maybe the ENV isn't set up for the cgi user?
try
use Env;
print "TZ=$ENV{TZ}\n";
print "LC_TIME=$ENV{LC_TIME}\n";
in the CGI script.

see perldoc perllocale

Code:
#!/usr/bin/perl  -s


use Env;

${TZ}="UTC";
print scalar localtime, "\n";

${TZ}="GB";
print scalar localtime, "\n";
Code:
billym>./1.pl
Wed Oct 10 12:48:33 2007
Wed Oct 10 13:48:33 2007

Last edited by bigearsbilly; 10-10-2007 at 07:55 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get time from my local machine munna_dude Programming 5 04-09-2007 02:35 AM
How to set local time? kornerr Linux - General 7 06-29-2005 02:24 PM
local time alaios Debian 1 12-08-2004 01:08 PM
ntpd not correcting local time plythgam Linux - Software 1 08-16-2004 04:12 PM
Running Perl CGI's on your own box with Apache leiavoia Linux - General 2 06-14-2002 06:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration