Thread: Server Question
View Single Post
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