Re: timelib diff working wrong on with years

From: Date: Wed, 11 Dec 2013 10:02:54 +0000
Subject: Re: timelib diff working wrong on with years
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-70587@lists.php.net to get a copy of this message
On Wed, Dec 11, 2013 at 5:38 PM, Nikita Nefedov <inefedor@gmail.com> wrote: > Hi, > > today I stumbled upon this bug, but I actually don't know should I call it > bug or is it right behavior? > > So for example lets get diff between 2013-10-25 and 2014-10-25: > var_dump((new DateTime("2013-03-25"))->diff(new DateTime("2014-03-25"))) > > We'll get one full year. > > Then if we try to get diff between 2012-03-25 and 2013-03-25 we'll also > get one year. > > But if we have 2012-03-01 and 2013-03-01 then we get 11 months and 30 days > (365 in int->days member)... > It gets interesting when you look one day around it: 2012-02-28 -> 2013-02-28 = 366 total, 1 year 2012-02-29 -> 2013-03-01 = 366 total, 1 year 2012-03-01 -> 2013-03-01 = 365 total, 11 months, 30 days 2013-03-02 -> 2013-03-02 = 365 total, 1 year > > Should we consider this as a bug or not? Seems like it; the total days is correct in all cases, but the breakdown doesn't look right. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#70587) next »