zby has asked for the wisdom of the Perl Monks concerning the following question:
I would expect it to count the days between the two dates. When examining $dur with Data::Dumper I discovered that it only remembers the difference in months - and since it does not know which months are involved it cannot count the days.use DateTime; use Data::Dumper; my $date = DateTime->now; my $dur = $date->subtract_datetime( DateTime->now->subtract( years => +1, months => 1 ) ); print "\nmonths: " . $dur->in_units( 'months' ) . "\ndays: " . $dur->i +n_units( 'days' ) . "\n"; __OUTPUT__ months: 13 days: 0 ^^^^^^^
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I count the days between two dates?
by ikegami (Patriarch) on Nov 04, 2008 at 17:24 UTC | |
by zby (Vicar) on Nov 05, 2008 at 09:50 UTC | |
|
Re: How can I count the days between two dates?
by Your Mother (Archbishop) on Nov 04, 2008 at 17:47 UTC | |
|
Re: How can I count the days between two dates?
by Fletch (Bishop) on Nov 04, 2008 at 17:46 UTC | |
by ikegami (Patriarch) on Nov 05, 2008 at 10:42 UTC | |
by Fletch (Bishop) on Nov 05, 2008 at 13:32 UTC |