php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65548 Comparison for DateTimeImmutable doesn't work
Submitted: 2013-08-25 14:03 UTC Modified: -
From: mail at roland-ramthun dot de Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.5.3 OS: 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: mail at roland-ramthun dot de
New email:
PHP Version: OS:

 

 [2013-08-25 14:03 UTC] mail at roland-ramthun dot de
Description:
------------
Comparison for DateTimeImmutable doesn't work. The same example with DateTime objects works.

Test script:
---------------
$a = new DateTimeImmutable('today');
$b = new DateTimeImmutable('tomorrow');

if ($a < $b) {
   print("yay");
}


Expected result:
----------------
yay

Actual result:
--------------
no output

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-27 23:44 UTC] cmbecker69 at gmx dot de
It seems that the comparison operators are not overloaded for
DateTimeImmutable objects.  Apparently they show the same behavior
as for arbitrary user defined classes.

If my assumption is correct, instead of adding a special treatment 
for the comparison operators wrt. DateTimeImmutable objects, it
might be considered to add a magic method __compare(). However,
I'm not sure, if this fits well with type juggling.
 [2013-09-12 13:15 UTC] nikic@php.net
Automatic comment on behalf of bsitnikovski@sugarcrm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d7f5f1ef35c32d6943cd76a3c51752e8d64c5e5e
Log: Fix bug #65548: Comparison for DateTimeImmutable doesn't work
 [2013-09-12 13:15 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of bsitnikovski@sugarcrm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d7f5f1ef35c32d6943cd76a3c51752e8d64c5e5e
Log: Fix bug #65548: Comparison for DateTimeImmutable doesn't work
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:28 2024 UTC