Days between two dates
Aaron Crane
perl at aaroncrane.co.uk
Thu Dec 22 15:45:17 GMT 2005
Paul Makepeace writes:
> A should-be-obvious question. How does one find the number of days
> between two dates, without converting to epoch?
With DateTime (as in your example) it looks like this:
$ perl -MDateTime -lwe '
$s = DateTime->new(year => 2005, month => 10, day => 1);
$d = DateTime->new(year => 2005, month => 12, day => 1);
print $d->delta_days($s)->delta_days'
61
Yes, it does seem bizarre that you call ->delta_days twice, on different
types of object.
--
Aaron Crane
More information about the london.pm
mailing list