Bug #68367 [Fbk->Opn]: Before 1915 datetime->diff works wrong

From: Date: Fri, 07 Nov 2014 13:40:24 +0000
Subject: Bug #68367 [Fbk->Opn]: Before 1915 datetime->diff works wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188509@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68367&edit=1

 ID:                 68367
 User updated by:    xguiga at gmail dot com
 Reported by:        xguiga at gmail dot com
 Summary:            Before 1915 datetime->diff works wrong
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   OSX Maveriks and Ubuntu 14.10
 PHP Version:        5.5.18
 Block user comment: N
 Private report:     N

 New Comment:

The timezone is: America/Sao_Paulo


Previous Comments:
------------------------------------------------------------------------
[2014-11-07 13:12:27] aharvey@php.net

What time zone is PHP using? You can check that with date_default_timezone_get().

------------------------------------------------------------------------
[2014-11-06 17:51:08] xguiga at gmail dot com

Description:
------------
I tried make an diff in 1899-01-01 and 1970-01-01 and don't return only year difference, return
months, days, hours, minutes and seconds.
I made some tests, and date before 1915 this happend.

Test script:
---------------
var_dump((new \DateTime('1912-01-01'))->diff(new \DateTime('1915-01-01')));

Expected result:
----------------
object(DateInterval)[2405]
  public 'y' => int 3
  public 'm' => int 0
  public 'd' => int 0
  public 'h' => int 0
  public 'i' => int 0
  public 's' => int 0
  public 'weekday' => int 0
  public 'weekday_behavior' => int 0
  public 'first_last_day_of' => int 0
  public 'invert' => int 0
  public 'days' => int 1095
  public 'special_type' => int 0
  public 'special_amount' => int 0
  public 'have_weekday_relative' => int 0
  public 'have_special_relative' => int 0


Actual result:
--------------
object(DateInterval)[2405]
  public 'y' => int 2
  public 'm' => int 11
  public 'd' => int 30
  public 'h' => int 23
  public 'i' => int 53
  public 's' => int 32
  public 'weekday' => int 0
  public 'weekday_behavior' => int 0
  public 'first_last_day_of' => int 0
  public 'invert' => int 0
  public 'days' => int 1095
  public 'special_type' => int 0
  public 'special_amount' => int 0
  public 'have_weekday_relative' => int 0
  public 'have_special_relative' => int 0


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



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


Thread (5 messages)

« previous php.bugs (#188509) next »