|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[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
[2010-09-29 14:02 UTC] cataphract@php.net
-Status: Open
+Status: Feedback
[2010-09-29 14:02 UTC] cataphract@php.net
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 17:00:01 2025 UTC |
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