php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68317 DateInterval hour eqal -1
Submitted: 2014-10-28 12:28 UTC Modified: 2014-10-28 12:46 UTC
From: romain dot chanu at ac-clermont dot fr Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.5.18 OS: Ubuntu
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: romain dot chanu at ac-clermont dot fr
New email:
PHP Version: OS:

 

 [2014-10-28 12:28 UTC] romain dot chanu at ac-clermont dot fr
Description:
------------
---
From manual page: http://www.php.net/class.dateinterval
---

Hi,

My PHP version is : 5.5.9-1ubuntu4.4

My application uses a function for calculating the difference in second between 2 DateTime(from string) using the "diff" method. It returns a DateInterval. It works fine but it seems DateInterval->h is not able to be equal to 23... When h property should be equal to 23 I got a "-1".

It seems very weird to got "-1"!

Test script:
---------------

$beginDate = new DateTime();
$endDate = new DateTime(); //24/10/2014 a 13h20
$stringDate = "24/10/2014 a 13h30";
$endDate = DateTime::createFromFormat('d/m/Y \a H\hi', $stringDate);
$diffDate = $endDate->diff($beginDate); //3 days 23 h 50m


echo "hours : $diffDate->h";

//returns hours : -1


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-28 12:46 UTC] romain dot chanu at ac-clermont dot fr
-Status: Open +Status: Closed
 [2014-10-28 12:46 UTC] romain dot chanu at ac-clermont dot fr
The problem is using diff with CEST date and a CET date.

My bad.

Sorry for any inconvenience this may cause.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC