Edit report at http://bugs.php.net/bug.php?id=52480&edit=1

 ID:                 52480
 Comment by:         fischer at wild-east dot de
 Reported by:        alex dot joyce at staff dot comcen dot com dot au
 Summary:            Incorrect difference using DateInterval
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   Debian 5.0.3
 PHP Version:        5.3.3
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

This happens only when setting a DateTime without the time part or a
time below 02:00:00. At least for the 'Europe/Berlin' timezone.


Previous Comments:
------------------------------------------------------------------------
[2010-07-30 10:46:55] der...@php.net

This is going to be a fun one to fix :-/

------------------------------------------------------------------------
[2010-07-30 01:40:02] alex dot joyce at staff dot comcen dot com dot au

Changing the timezone shows a difference.



Australia/Sydney (default): 5 months

UTC: 4 months 28 days

------------------------------------------------------------------------
[2010-07-29 09:35:01] degeb...@php.net

With the timezone set to Europe/Copenhagen, I get the same results as
submitter. When set to UTC, I get the same results on Rasmus. This is on
Ubuntu 10.04.



daniel@daniel-laptop:~$ php -v

PHP 5.3.4-dev (cli) (built: Jul 29 2010 09:30:24) 

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

------------------------------------------------------------------------
[2010-07-29 09:15:41] ras...@php.net

I don't see why I can't reproduce it then.  Try adding a call to 

date_default_timezone_set() to the top of your script and work in UTC to


eliminate local timezone issues.  



  date_default_timezone_set('UTC');

  $date_start = new DateTime('2010-03-01');

  $date_end   = new DateTime('2010-07-29');

  $interval = $date_start->diff($date_end);

  print_r($interval);

------------------------------------------------------------------------
[2010-07-29 08:52:20] alex dot joyce at staff dot comcen dot com dot au

28/29, it doesn't matter. I'm only interested in the months.



I've tried:



1) FreeBSD 6, PHP 5.3.2

2) Debian 4, PHP 5.3.2

3) Debian 6, PHP 5.3.2/PHP 5.3.3



I upgraded that last one to submit this bug report, same fault.



All compiled from source.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52480


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52480&edit=1

Reply via email to