#44536 [Opn->Bgs]: wrong result (timestamp)
| From: | jani@php.net | Date: | Wed, 26 Mar 2008 12:01:07 +0000 |
| Subject: | #44536 [Opn->Bgs]: wrong result (timestamp) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-123656@lists.php.net to get a copy of this message | ||
ID: 44536
Updated by: jani@php.net
Reported By: anas1305 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: XP and Linux
PHP Version: 5.2CVS-2008-03-26
New Comment:
Congratulations! You have found the DST (daylight saving time) and it's
problems. :) Hint: Use gmmktime() instead and you'll never encounter
this in the future.
Previous Comments:
------------------------------------------------------------------------
[2008-03-26 11:28:22] anas1305 at gmail dot com
Description:
------------
function return wrong result between 2 dates 2008-03-30 -> 2008-03-31.
PHP version : 5.2.3
Reproduce code:
---------------
$ddebut = "2008-03-30";
$dfin = "2008-03-31";
$tab_ddebut = explode("-", $ddebut);
$tab_dfin = explode("-", $dfin);
$timestamp_ddebut = mktime(0, 0, 0, $tab_ddebut[1], $tab_ddebut[2],
$tab_ddebut[0]);
$timestamp_dfin = mktime(0, 0, 0, $tab_dfin[1], $tab_dfin[2],
$tab_dfin[0]);
echo abs(($timestamp_dfin - $timestamp_ddebut)/86400);
Expected result:
----------------
this code abs(($timestamp_dfin - $timestamp_ddebut)/86400) return wrong
result : 0.958333333333. the correct result is 1.
Actual result:
--------------
0.958333333333
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44536&edit=1