Doc #76069 [NEW]: date_diff

From: Date: Thu, 08 Mar 2018 15:33:00 +0000
Subject: Doc #76069 [NEW]: date_diff
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15504@lists.php.net to get a copy of this message
From:             pustka-phpnet at lkn dot pl
Operating system: windows
PHP version:      7.1.15
Package:          *General Issues
Bug Type:         Documentation Problem
Bug description:date_diff

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 bug report at https://bugs.php.net/bug.php?id=76069&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76069&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76069&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76069&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76069&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76069&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76069&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76069&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76069&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76069&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76069&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76069&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76069&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76069&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76069&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76069&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76069&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76069&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76069&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76069&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76069&r=mysqlcfg



Thread (3 messages)

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