php.net |  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
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bfrance@php.net 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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bfrance@php.net
New email:
PHP Version: OS:

 

 [2007-08-22 09:15 UTC] bfrance@php.net
Description:
------------
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");




Patches

Pull Requests

History

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] derick@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC