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

 ID:                 54582
 Updated by:         ras...@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

Reply via email to