Bug #54655 [Opn->Nab]: unable to compare timezones instance with == operator

From: Date: Thu, 12 Jan 2017 20:02:57 +0000
Subject: Bug #54655 [Opn->Nab]: unable to compare timezones instance with == operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206576@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54655&edit=1 ID: 54655 Updated by: heiglandreas@php.net Reported by: giorgio dot liscio at email dot it Summary: unable to compare timezones instance with == operator -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: any? PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Comparing two classes with "==" checks whether both are instances of t he same classes. If you want to compare also whether they are the same you have to use "===" to do so. Have a look at https://3v4l.org/EZQnF Regarding the comparison <= or >= the main question arising is: What makes one timezone higher or lower than the other one? You can not rank timezones. Previous Comments: ------------------------------------------------------------------------ [2013-04-11 06:54:57] info at giorgiosironi dot com I confirm this on PHP 5.4: [08:45:57][giorgio@Galen:~]$ php -r "var_dump(new DateTimeZone('Europe/Rome') == new DateTimeZone('America/New_York'));" bool(true) [08:46:12][giorgio@Galen:~]$ php -v PHP 5.4.9-4~oneiric+1 (cli) (built: Nov 30 2012 10:46:16) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans ------------------------------------------------------------------------ [2012-01-30 21:36:04] kavi at postpro dot net bump ------------------------------------------------------------------------ [2011-05-04 11:26:13] giorgio dot liscio at email dot it Description: ------------ just a cosmetic problem $a = new \DateTimeZone("Europe/Rome"); $b = new \DateTimeZone("Europe/Athens"); var_dump($a == $b); // true... not so nice var_dump($a->getName() == $b->getName()); // false, good all other classes of datetime lib can be compared using various operators, but not datetimezone would be nice having this working too, if possible: var_dump($a >= $b); var_dump($a <= $b); thank you ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54655&edit=1

« previous php.bugs (#206576) next »