Doc #76069 [Opn->Ctl]: date_diff

From: Date: Mon, 12 Mar 2018 15:36:42 +0000
Subject: Doc #76069 [Opn->Ctl]: date_diff
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15511@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76069&edit=1 ID: 76069 Updated by: cmb@php.net Reported by: pustka-phpnet at lkn dot pl Summary: date_diff -Status: Open +Status: Critical Type: Documentation Problem Package: Date/time related Operating System: windows PHP Version: 7.1.15 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This looks like being a duplicate of bug #65003. Previous Comments: ------------------------------------------------------------------------ [2018-03-08 15:32:57] pustka-phpnet at lkn dot pl Description: ------------ --- From manual page: http://www.php.net/function.date-diff --- In some cases date_diff() function shows differenece in days instead of months. Test script: --------------- $dateS = new DateTime('2018-03-01'); $dateE = new DateTime('2018-04-01'); print_r(date_diff($dateS, $dateE)); $dateS = new DateTime('2018-02-01'); $dateE = new DateTime('2018-03-01'); print_r(date_diff($dateS, $dateE)); Expected result: ---------------- DateInterval Object ( [y] => 0 [m] => 1 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 31 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) DateInterval Object ( [y] => 0 [m] => 1 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 28 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) Actual result: -------------- DateInterval Object ( [y] => 0 [m] => 1 [d] => 3//why 3? [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 31 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) DateInterval Object ( [y] => 0 [m] => 0//why 0? [d] => 28//and why 28? [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 28 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76069&edit=1

« previous php.doc.bugs (#15511) next »