Bug #51755 [Com]: date_diff and DateTime::diff break next operation with float variable

From: Date: Sat, 08 May 2010 01:56:51 +0000
Subject: Bug #51755 [Com]: date_diff and DateTime::diff break next operation with float variable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150257@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51755&edit=1

 ID:               51755
 Comment by:       phpbugs at mise dot x25 dot se
 Reported by:      thalamicek at gmail dot com
 Summary:          date_diff and DateTime::diff break next operation with
                   float variable
 Status:           Feedback
 Type:             Bug
 Package:          Variables related
 Operating System: Windows 7 Professional
 PHP Version:      Irrelevant

 New Comment:

A hilarious workaround until this is fixed:

$test = new DateTime("2007");
$test->diff(new DateTime("2008"));
print_r(3 / 2, 1); // trigger bug, do nothing, resume
print 1000 / 3;


Previous Comments:
------------------------------------------------------------------------
[2010-05-06 12:56:59] derick@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

------------------------------------------------------------------------
[2010-05-06 12:35:45] thalamicek at gmail dot com

Description:
------------
When using function date_diff or DateTime::diff, next operation (math,
print etc.) 
with variable type float fails. I got results as float(>.J), but only
for first 
operation. This issue can persists to next script process(first contains
date_diff 
function, next contains operation with float variable)

PHP ver 5.3.1

Test script:
---------------
$a = 141.4;

var_dump($a);

$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$datetime1->diff($datetime2);

var_dump($a);
var_dump($a);

Expected result:
----------------
float(141.4) float(141.4) float(141.4)

Actual result:
--------------
float(141.4) float(>.J) float(141.4)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51755&edit=1


Thread (4 messages)

« previous php.bugs (#150257) next »