[thelist] Dates in Perl

Joxn joxn at vernum.com
Mon Sep 18 08:51:44 CDT 2000


Hi Adrian,
> Now to the problem at hand.  I have a form in which I want the user to tell
> me a date.  ie their birthday.
> I want to use select options with the months in one list and the number of
> days in the other.  Years I'm not worried about (yet...unless I have to).
> Can the info from those form fields be turned into a usable thing in perl?

I'm not that sure if I'm on the right track here, but I'm using the
"str2time" function provided by the HTTP::Date module in Perl. Just put
"use HTTP::Date qw(str2time);" at the beginning of your script - works
only if the module is installed, of course.

For example, in EveryAuction I used the following code to figure out
when an auction ends. The $form vars. are entered by the user.

$enddate = $form{'ENDYEAR'} . "-" . $form{'ENDMONTH'} . "-" .
$form{'ENDDAY'} . " " . $form{'ENDHOUR'} . ":" . $form{'ENDMINUTE'};

$form{'ITEM'} = str2time($enddate);

The result is an unix timestamp which then can be used in various ways
in Perl.

I don't know if str2time accepts other format-strings, just take a look
at the documentation.

Hope this helps.

bye Joxn
-- 
   || //\\ \\// |\\||  ::  mailto:joxn at vernum.com  ::
 \\|| \\// //\\ ||\\|  ::      ICQ:8053703         ::




More information about the thelist mailing list