in reply to How Many Days in the Past?

Check out Date::Manip

Some examples from the docs:

2. Compare two dates
$date1=&ParseDate($string1); $date2=&ParseDate($string2); $flag=&Date_Cmp($date1,$date2); if ($flag<0) { # date1 is earlier } elsif ($flag==0) { # the two dates are identical } else { # date2 is earlier }
4. The amount of time between two dates.
$date1=&ParseDate($string1); $date2=&ParseDate($string2); $delta=&DateCalc($date1,$date2,\$err); => 0:0:WK:DD:HH:MM:SS the weeks, days, hours, minutes, and seconds between the two $delta=&DateCalc($date1,$date2,\$err,1); => YY:MM:WK:DD:HH:MM:SS the years, months, etc. between the two


There are many more examples/"recipes" contained in the docs.

HTH

Replies are listed 'Best First'.
Re: Re: How Many Days in the Past?
by tinman (Curate) on Apr 23, 2001 at 21:19 UTC

    As a followup, try the code snippet in this node.. it requires Date::Manip to be installed, and allows the specification of parameters, such as minute, hour and day.. ie: you can check to see the epoch time in seconds, 2 hours ago from the present time..

    I don't know if you're running this in Win32 or Unix, but if its Win32,Linux or Solaris and if you have ActivePerl, you don't need a C compiler to install Date::Manip, because the PPM repository has it compiled and ready to install..
    HTH