Hi Mattew,

> $birth=DateTime->new(year=>1968,month=>6,day=>28);
> print $birth->ymd."\n";
> $today=DateTime->today;
> print $today->ymd."\n";
> $age=$today-$birth;
> print $age->years."\n";

$age is a DateTime::Duration object.   Unfortunately math with these object can be a 
little non-intuitive.

> I get this output:
>
> 1968-06-28
> 2003-08-17
> 0

Try:

print $age->deltas, "\n";

If the output from that doesn't look right to you please send it on to the list.

> That zero sure doesn't seem correct to me.

It means zero year 'units' - that doesn't preclude other 'units' adding up to year+ 
values.

Cheers,

-J

--

Reply via email to