Try the moudle
Date::Simple ... very simple interface for calculations between two dates.
Code:
use Date::Simple ('date', 'today');
# Difference in days between two dates:
$diff = date('2001-08-27') - date('1977-10-05');
Or you can use a more round-about method:
Code:
use Time::Local;
my $this = "13/02/1982"; # my birthday
my $that = "19/09/1983"; # my sister's birthday
my $seconds_diff = date_to_sec($that) - date_to_sec($this);
my $days_diff = int($seconds_diff / 86400);
print "I am $days_diff days older than my sister.\n";
sub date_to_sec {
my ($mon, $day, $year) = map { s/^0+//; $_ } split '/', shift;
return timelocal(0,0,12, $day, $mon - 1, $year - 1900);
}
Hope this helps!
- wil