develooper Front page | perl.datetime | Postings from March 2006

Re: difference in days

Thread Previous
From:
Dave Rolsky
Date:
March 6, 2006 09:00
Subject:
Re: difference in days
Message ID:
Pine.LNX.4.64.0603061059290.20407@urth.org
On Tue, 28 Feb 2006, Praveen Ray wrote:

> Is there a way to get the difference in days , between two dates?
>
> $dur  = $dt1 - $dt2;
>
> print $dur->days,"\n"
>
> prints days between two dates after factoring out higher units (as the 
> documentation says).
> How do I get the difference in 'days' ?

There's a couple things you can do:

First, do this:

  $dur = $dt1->delta_days($dt2);

  print $dur->days;

Alternately, you use DateTime::Format::Duration to take an existing 
duration object and get various values out of it.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About