or use Date::Calc qw(Delta_Days);
here's the relevant example from the perldoc:
o $Dd = Delta_Days($year1,$month1,$day1,$year2,$month2,$day2);
This function returns the difference in days between the
two given dates.
The result is positive if the two dates are in
chronological order, i.e., if date #1 comes
chronologically BEFORE date #2, and negative if the
order of the two dates is reversed.
Date::Calc - practically every conceivable bit of date arithmetic in one
module.
alex
On Tue, 27 Mar 2001, David Cantrell wrote:
> On Tue, Mar 27, 2001 at 11:07:30PM +0100, Natalie Ford wrote:
>
> > I need to put a countdown to a specific date on a web page. Can anyone
> > tell me the best way to do this? Is there something I have missed in HTML
> > itself that will do this? Do I need JavaScript or Perl or ANOther? Any
> > help will be much appreciated as I need to do this in a relatively short
> > time-frame (the next three days?!!)...
>
> If you want the countdown to continually update after the page has loaded,
> then you need Java[script]. If, however, you simply want to put a static
> value into the page, then a bit o' perl like this should suffice (untested):
>
> $futuretime=1e9; # the epoch time of your future event
> $timediff=$futuretime-time;
>
> exit if($timediff<1); # don't want to have embarrassing negative numbers ...
>
> $days=int($timediff/86400); $timediff%=86400 # 86400 seconds in a day
> $hours=int($timediff/3600); $timediff%=3600 # 3600 seconds in an hour
> $mins=int($timediff/60); $timediff%=60 # 60 seconds in a minute
> $secs=$timediff;
>
> print "$days Days, $hours Hours, $mins Minutes and $secs Seconds remain.";
>
> Prettifying, and getting the correct singulars/plurals in there is left as
> an exercise for the reader. Months are a little tricky so I haven't
> bothered :-)
>
>
--
____________________________________________________
alex nunes | t 020 7603 5723 | f 020 7603 2504
director | read the NEW story @ http://codix.net/
codix.net | 107 shepherd's bush road, london w6 7lp