Bug #54582 [Opn->Bgs]: Division is not preferred to substraction
| From: | rasmus@php.net | Date: | Thu, 21 Apr 2011 02:04:09 +0000 |
| Subject: | Bug #54582 [Opn->Bgs]: Division is not preferred to substraction | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160320@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54582&edit=1
ID: 54582
Updated by: rasmus@php.net
Reported by: fs at coresec dot de
Summary: Division is not preferred to substraction
-Status: Open
+Status: Bogus
Type: Bug
Package: Math related
Operating System: Debian Squeeze
PHP Version: 5.3SVN-2011-04-21 (snap)
Block user comment: N
Private report: N
New Comment:
You might want to rethink your code there :)
time()/60*60*24 is going to give you the approximate number of days
since 1970
which is a bit over 15000. your strtotime() is going to return the
number of
seconds since 1970. Then you subtract the number of days from the
number of
seconds? That makes no sense, but PHP is doing exactly what you are
asking for.
You should be using http://php.net/datetime for stuff like
this anyway,
not
timestamps.
Previous Comments:
------------------------------------------------------------------------
[2011-04-21 03:55:21] fs at coresec dot de
Description:
------------
When dealing with a MySQL-Datetime Tiemstamp i've encountered the
following Bug which leads to an error resulting in a wrong integer
(resulting days).
$mysql is an array containing a mysql datetime at point [6]
"2011-06-21"
If $mysql[6] is in the future and time() is the present unix-timestamp
we're getting a wrong result in $remaining (days).
Test script:
---------------
$remaining = floor(strtotime(str_replace('-','',$mysql[6])) -
time()/(60*60*24));
Expected result:
----------------
29
Actual result:
--------------
1305920914
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54582&edit=1