|  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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
4 + 27 = ?
Subscribe to this entry?

 [2014-10-28 12:28 UTC] romain dot chanu at ac-clermont dot fr
From manual page:


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


Add a Patch

Pull Requests

Add a Pull Request


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: Sun May 19 11:01:37 2024 UTC