in reply to Comparing two dates and getting back difference in days
Cheers - L~R#!/usr/bin/perl -w use strict; use Time::Local; use Seconds2English; my $date1 = epoch('2004-01-14'); my $date2 = epoch('2003-12-25'); my $diff = Seconds2English->new('start' => $date2 - $date1); print "The difference is " , $diff->in_days, " days\n"; sub epoch { my ($year, $month, $day) = split '-' , shift; return timelocal(0 , 0 , 12, $day , $month - 1, $year); } __END__ The difference is 20 days
|
|---|