|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42372 [DateTime] Difference function
Submitted: 2007-08-22 09:15 UTC Modified: 2008-07-07 19:55 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned: derick (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5CVS-2007-08-22 (CVS) OS: doesn't matter
Private report: No CVE-ID: None
 [2007-08-22 09:15 UTC]
Would be nice if DateTime had some sort of differences functions.

Something that could get around the 2038 issue of this:

$diffTime = strtotime($endDateString) - strtotime($startDateString)

may be something like this:

$endDateString = new DateTime("@$X");

$diffTime = $endDateString->difference("@$Y");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-11 16:26 UTC] diana dot woodhouse at unc dot edu
does anyone have a workaround for the datetime difference functionality? Simple subraction and addition of strototime values don't work?
 [2008-07-07 19:55 UTC]
This has been implemented for PHP 5.3 in the form of the date_diff() function and the diff() method of the DateTime class.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 11:01:26 2023 UTC