
japhy
Enthusiast
Apr 14, 2000, 4:41 AM
Post #4 of 5
(530 views)
|
I'm sorry, I misinterpreted the question. Well, you need to know what format they're entering the date in. After you've gotten into a workable format, I'd use the standard distribution Time::Local module. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> use Time::Local; $time = timelocal($s,$m,$h,$day,$mon,$yr); $yday = (localtime($time))[7]; </pre><HR></BLOCKQUOTE> The values for timelocal()'s arguments must be in the same format as localtime() returns. That means seconds are 0 -> 59, minutes are 0 -> 59, hours are 0 -> 23, day is 1 -> 31, month is 0 -> 11, and year is the current year - 1900. Example call: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> use Time::Local; # the stroke of midnight on my birthday $time = timelocal(0,0,0,9,11,81); $yday = (localtime($time))[7]; print "I was born on day $yday of the year."; </pre><HR></BLOCKQUOTE>
|