Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2008-01-24, 03:40 PM   #1
ecchi
Banned
 
ecchi's Avatar
 
Join Date: Oct 2003
Location: About to be evicted!!!!
Posts: 4,082
Server Question

Can anyone who sets up or manages servers help me with this question:

I have a new domain on a new server. When running Perl scripts I cannot get DATE_GMT or DATE_LOCAL to work. Perl requests like: $gmtdate = $ENV{'DATE_GMT'}; and $localdate = $ENV{'DATE_LOCAL'}; return an empty string. When I asked my host about this they said to include the following SSI into my HTML:
Code:
<!--#set var="year" value="$DATE_GMT" -->
<!--#set var="year" value="$DATE_LOCAL" -->
This obviously does the job, but I cannot help assuming that the problem is that something is missing or out of date on the server (old version of Perl, old version of server software, or something). Anyone know exactly what the problem is, as my host is good except in one respect: when they make a mistake they fix it but when I ask what the problem was they either lie to cover it up or just don't reply.

If it helps I have the following server info:
SERVER_SOFTWARE = Apache/2.2.6 (Fedora)
SERVER_PROTOCOL = INCLUDED
GATEWAY_INTERFACE = CGI/1.1

Thanks.
ecchi is offline   Reply With Quote
Old 2008-01-24, 10:19 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Those Environment variables won't always be available in CGI, so, you really cannot depend on them. SSI parses them using the Apache environment which does set those variables.

You could do something like:

Code:
print "Content-type: text/html\n\n";
print `date`;
print `date -u`;
date also takes format codes.

Code:
print `date "+%b %d, %Y"`;
Its not really the best way to do it because you do fork one process to get the date, but, it does work.

There are also calendar libraries available or you could write something using localtime/gmtime

Code:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                                localtime(time);
printf "%d/%d/%d",$mon+1,$mday,$year+1900;
A much preferred method to forking a call to date. You can replace localtime(time) with localtime(gmtime) for UTC.

Remember that $mon returns 0-11 for Jan-Dec, and the year needs 1900 added to it.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:41 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc