|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-18 10:04 UTC] ryosuke_i_628 at yahoo dot co dot jp
[2017-04-24 15:57 UTC] heiglandreas@php.net
-Status: Open
+Status: Duplicate
[2017-04-24 15:57 UTC] heiglandreas@php.net
[2017-09-16 05:51 UTC] ryosuke_i_628 at yahoo dot co dot jp
[2017-09-16 09:29 UTC] spam2 at rhsoft dot net
[2017-09-16 11:44 UTC] ryosuke_i_628 at yahoo dot co dot jp
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ I've tested this on v5.6.15, but in changelog from 5.6.15 to 5.6.18 there is nothing about datetime so this bug seems to be not fixed also in 5.6.18. If we change the month in a sample code from march to april, the result is the same for both comparisons (1 year 0 days 0 months). Also if we change the day in sample code from 01 to 02 and stay with march, the result is also the same. But for original code attached, the result is different but should be also the same. Test script: --------------- <?php $start = new DateTime('01.03.2016'); $end = new DateTime('01.03.2017'); $diff = $end->diff($start); var_dump($start->format('d-m-Y'), $end->format('d-m-Y'), $diff); $start = new DateTime('02.03.2016'); $end = new DateTime('02.03.2017'); $diff = $end->diff($start); var_dump($start->format('d-m-Y'), $end->format('d-m-Y'), $diff); Expected result: ---------------- string '01-03-2016' (length=10) string '01-03-2017' (length=10) object(DateInterval)[3] public 'y' => int 1 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 1 public 'days' => int 365 public 'special_type' => int 0 public 'special_amount' => int 0 public 'have_weekday_relative' => int 0 public 'have_special_relative' => int 0 string '02-03-2016' (length=10) string '02-03-2017' (length=10) object(DateInterval)[2] public 'y' => int 1 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 1 public 'days' => int 365 public 'special_type' => int 0 public 'special_amount' => int 0 public 'have_weekday_relative' => int 0 public 'have_special_relative' => int 0 Actual result: -------------- string '01-03-2016' (length=10) string '01-03-2017' (length=10) object(DateInterval)[3] public 'y' => int 0 public 'm' => int 11 public 'd' => int 28 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 1 public 'days' => int 365 public 'special_type' => int 0 public 'special_amount' => int 0 public 'have_weekday_relative' => int 0 public 'have_special_relative' => int 0 string '02-03-2016' (length=10) string '02-03-2017' (length=10) object(DateInterval)[2] public 'y' => int 1 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 1 public 'days' => int 365 public 'special_type' => int 0 public 'special_amount' => int 0 public 'have_weekday_relative' => int 0 public 'have_special_relative' => int 0