php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52920 Multiple datetime affects divisions
Submitted: 2010-09-24 17:25 UTC Modified: 2013-02-18 00:34 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:5 of 6 (83.3%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: michael at nerdalert dot biz Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.3.3 OS: Windows Server 2008 R2 Enterpris
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michael at nerdalert dot biz
New email:
PHP Version: OS:

 

 [2010-09-24 17:25 UTC] michael at nerdalert dot biz
Description:
------------
The result of this equation (echo 240 / 23;) is NAN in each occurrence when I run DateTime class before the equation. The datetime class needs to be run multiple times to get the NAN result (for ($a=0;$a<2;$a++){). 



Test script:
---------------
for ($a=0;$a<2;$a++){
	$lastResponse = date("Y-m-d");	
	$noResponse = date("Y-m-d");	
	$dateCreated = new DateTime(date("Y-m-d", strtotime($lastResponse)));
	$dateNotCreated = new DateTime(date("Y-m-d", strtotime($noResponse)));
	$today = new DateTime(date("Y-m-d"));
	
	if(isset($lastResponse))
	{
		$diff = $today->diff($dateCreated);
	}
	else
	{
		$diff = $today->diff($dateNotCreated);
	}
}
echo 240 / 23;

Expected result:
----------------
Not NAN

Actual result:
--------------
NAN

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-24 17:27 UTC] michael at nerdalert dot biz
-Summary: Division equations are overridden +Summary: Multiple datetime affects divisions
 [2010-09-24 17:27 UTC] michael at nerdalert dot biz
Changing the title only
 [2010-09-29 14:02 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2010-09-29 14:02 UTC] cataphract@php.net
I can't reproduce this with PHP 5.3.3.

What binaries are you using? (thread safety or not, vc6 or vc9)
 [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: Tue Oct 19 16:03:35 2021 UTC