Still using Date::Calc, here is a much easier way to do what I posted
earlier:
use Date::Calc qw(:all);
$dd = Delta_Days(Today(), 2002, 1, 23);
print "$dd\n";
In that case it is giving the difference between January 23, 2002 and today
in days. I had forgotten about the "Today" function when I wrote the earlier
one. There is a "Now" function that works like today except that is returns
hours minutes and seconds of the time, and a Today_and_Now function that
returns both.
Anyway, I thought I'd post the simpler way - so you don't have to do any
further manipulations of system dates to get there.
Steve H.
-----Original Message-----
From: Jeff 'japhy/Marillion' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 22, 2001 9:37 AM
To: Steve Howard
Cc: Ackim Chisha; [EMAIL PROTECTED]
Subject: RE: Dates subtraction
On Jul 22, Steve Howard said:
>Have you installed and DATE::CALC. If so you would do something like
>this:
>
>my $dd = Delta_Days(@th{year, mon, mday}, @expiatory);
I far prefer the simpler (and standard-module) approach of the Time::Local
module. This module is a tool you should get to know well.
use Time::Local;
my ($bd, $bm, $by) = (9, 11, 1981); # my birthday
my ($nd, $nm, $ny) = (localtime)[3..5]; # today
my $start = timelocal(0,0,12, $bd, $bm-1, $by-1900); # noon of b'day
my $end = timelocal(0,0,12, $nd, $nm, $ny); # noon today
my $sec_diff = $end - $start;
my $day_diff = int( $sec_diff / 86400 );
print "I am $day_diff days old!\n";
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]