Edit report at http://bugs.php.net/bug.php?id=54582&edit=1
ID: 54582 Comment by: fs at coresec dot de Reported by: fs at coresec dot de Summary: Division is not preferred to substraction 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: OMFG! I'm so sorry about this - pretty late here in Germany :( It was absolutely my fault as i didnt set the brakets correctly. $remaining = floor((strtotime(str_replace('-','',$proxy[6])) - time())/(60*60*24)); Works as aspected - i am sorry for this bugreport - should have triple-checked it before posting it. Have a sunny weekend guys! Previous Comments: ------------------------------------------------------------------------ [2011-04-21 04:04:09] ras...@php.net 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. ------------------------------------------------------------------------ [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