Gossamer Forum
Home : General : Perl Programming :

How to get date in cgi-script on nt?

Quote Reply
How to get date in cgi-script on nt?
Hi

I get this message in a "similar guestbok" classified: "The system cannot accept the date entered. Enter the new date: (yy-mm-dd)"

The cgi-script code looks like this:
# Get the Date for Entry
$date = `date +"%A, %B %d, %Y"`;
chop($date);
$shortdate = `date +"%D"`;
chop($shortdate);


Basically, I look for code that returns current date. Anybody??? I am on NT, with perl modules.



Quote Reply
Re: How to get date in cgi-script on nt? In reply to
Use the sub date_to_unix and sub get_date located in DBMAN and LINKS. Make sure that you have installed the recent build of Perl 5.00503 from ActiveState, which includes the recent Local.pm module used in these routines.

Then to call the current date...use one of the following:

Code:
$date = &get_date;
Today's Date: $date

Code:
&get_date

If you are trying to the pull the date via a SSI call, use ASP to create an asp page, and you can use perl as the programming language for the ASP page.

For an example, check out:

www.coco.cc.az.us/default.asp

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: How to get date in cgi-script on nt? In reply to
($sec,$min,$hour,$day,$month,$year,$day2) = (localtime(time));
print "$year-$month-$day\n";
Quote Reply
Re: How to get date in cgi-script on nt? In reply to
Ilya, almost correct. Except, that the year will print as 100 and the month will be one shy.

Read perldoc -f localtime for an explanation of why, and what must be done to correct it.

And actually, if only the date is needed,
($mday, $mon, $year) = (localtime(time))[3..5];

is needed.

--Mark