Bug #68187 [Com]: Strange behavior DateInterval in PHP
| From: | camporter1 at gmail dot com | Date: | Mon, 13 Oct 2014 05:11:37 +0000 |
| Subject: | Bug #68187 [Com]: Strange behavior DateInterval in PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188046@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68187&edit=1
ID: 68187
Comment by: camporter1 at gmail dot com
Reported by: e45456 at yandex dot ru
Summary: Strange behavior DateInterval in PHP
Status: Open
Type: Bug
Package: Date/time related
Operating System: Ubuntu 14
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I spent a bit of time trying to debug this, and noticed that the properties hashtable for the
DateInterval object that is being dumped ends up getting elements added when using the get
properties handler, whereas the other DateInterval's properties hashtable remains empty, since
it isn't dumped.
The first comparison notices that both have the same element count, which causes the first result to
be false. The second comparison sees that one properties hashtable has 15 elements vs 0 elements,
due to having been dumped.
Previous Comments:
------------------------------------------------------------------------
[2014-10-08 13:54:39] e45456 at yandex dot ru
Description:
------------
Strange behavior DateInterval in PHP.
I think it is a php bug.
Test script:
---------------
$i1 = DateInterval::createFromDateString('10 minutes');
$i2 = DateInterval::createFromDateString('30 minutes');
var_dump($i1 > $i2);
var_dump($i1 > $i2);
var_dump($i1);
var_dump($i1 > $i2);
var_dump($i1 > $i2);
Expected result:
----------------
bool(false)
bool(false)
object(DateInterval)#3 (8) {
...
}
bool(false)
bool(false)
Actual result:
--------------
bool(false)
bool(false)
object(DateInterval)#3 (8) {
...
}
bool(true)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68187&edit=1