Bug #71511 [NEW]: Diff for februari not a month
| From: | efrkool at live dot nl | Date: | Wed, 03 Feb 2016 13:38:23 +0000 |
| Subject: | Bug #71511 [NEW]: Diff for februari not a month | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-199024@lists.php.net to get a copy of this message | ||
From: efrkool at live dot nl
Operating system: CentOS Linux release 7.2.1511 (C
PHP version: 5.6.17
Package: Date/time related
Bug Type: Bug
Bug description:Diff for februari not a month
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 bug report at https://bugs.php.net/bug.php?id=71511&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71511&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71511&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71511&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71511&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71511&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71511&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71511&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71511&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71511&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71511&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71511&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71511&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71511&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71511&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71511&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71511&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71511&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71511&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71511&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71511&r=mysqlcfg