Bug #71511 [Opn->Dup]: Diff for februari not a month
| From: | heiglandreas@php.net | Date: | Mon, 24 Apr 2017 15:54:54 +0000 |
| Subject: | Bug #71511 [Opn->Dup]: Diff for februari not a month | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208747@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71511&edit=1
ID: 71511
Updated by: heiglandreas@php.net
Reported by: efrkool at live dot nl
Summary: Diff for februari not a month
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: CentOS Linux release 7.2.1511 (C
PHP Version: 5.6.17
Block user comment: N
Private report: N
New Comment:
This seems to be a duplicate of https://bugs.php.net/bug.php?id=52480
Previous Comments:
------------------------------------------------------------------------
[2016-02-03 13:38:19] efrkool at live dot nl
Description:
------------
When calculating the number of months between the 1st of februari and the 1st of march I espect it
to return 1 month but it returns 0.
I first tought this had to do with the leap year but that doesn't have anything to do with it
becouse it also happens for 2015.
Test script:
---------------
<?php
$first = new \DateTime('2016-02-01 00:00:00', new
\DateTimeZone('Europe/Amsterdam'));
$second = new \DateTime('2016-03-01 00:00:00', new
\DateTimeZone('Europe/Amsterdam'));
$diff = $first->diff($second);
echo $diff->format('%m') . PHP_EOL;
// Expect: 1, got 0
$second->modify('+1 month');
$diff2 = $first->diff($second);
echo $diff2->format('%m') . PHP_EOL;
// Expect: 2, got 2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71511&edit=1