php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44536 wrong result (timestamp)
Submitted: 2008-03-26 11:28 UTC Modified: 2008-03-26 12:01 UTC
From: anas1305 at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2CVS-2008-03-26 OS: XP and Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anas1305 at gmail dot com
New email:
PHP Version: OS:

 

 [2008-03-26 11:28 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-26 12:01 UTC] jani@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 16:01:30 2024 UTC