Bug #69587 [Ver]: DateInterval properties and isset
Edit report at https://bugs.php.net/bug.php?id=69587&edit=1
ID: 69587
Updated by: cmb@php.net
Reported by: charlesw at ex-situ dot com
Summary: DateInterval properties and isset
Status: Verified
Type: Bug
Package: Date/time related
Operating System: CentOS / OSX / Other
PHP Version: 5.6.8
Block user comment: N
Private report: N
New Comment:
Closely related to bug #67934.
Previous Comments:
------------------------------------------------------------------------
[2015-05-06 20:15:59] cmb@php.net
DateTime doesn't belong to SPL, so I changed the package and the summary.
Otherwise verified: <http://3v4l.org/D7bcM>. Seems to be
related to bug #67621.
------------------------------------------------------------------------
[2015-05-06 19:22:22] charlesw at ex-situ dot com
Description:
------------
Testing public properties on DateInterval objects with isset returns false even when they contain
data. Running a print_r or var_dump on the object BEFORE testing isset will provide the desired
result.
Test script:
---------------
$currentDate = new DateTime();
$targetDate = new DateTime('2015-03-05 11:11:11');
$interval = $currentDate->diff($targetDate);
// var_dump($interval); // Uncomment and isset will give the expected response
var_dump($interval->y);
var_dump($interval->m);
var_dump(isset($interval->y));
var_dump(isset($interval->m));
Expected result:
----------------
int(0)
int(2)
bool(true)
bool(true)
Actual result:
--------------
int(0)
int(2)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69587&edit=1
Thread (5 messages)