|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51755 date_diff and DateTime::diff break next operation with float variable
Submitted: 2010-05-06 12:35 UTC Modified: 2013-02-18 00:34 UTC
Avg. Score:4.1 ± 0.9
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:6 (85.7%)
From: thalamicek at gmail dot com Assigned:
Status: No Feedback Package: Variables related
PHP Version: Irrelevant OS: Windows 7 Professional
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-05-06 12:35 UTC] thalamicek at gmail dot com
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;


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


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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-06 12:56 UTC]
-Status: Open +Status: Feedback
 [2010-05-06 12:56 UTC]
Please try using this snapshot:
For Windows:
 [2010-05-08 03:56 UTC] phpbugs at mise dot x25 dot se
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;
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 12:03:36 2021 UTC