note 129158 added to datetime.diff
| From: | php at markuszeller dot com | Date: | Sat, 13 Jan 2024 13:16:04 +0000 |
| Subject: | note 129158 added to datetime.diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221112@lists.php.net to get a copy of this message | ||
Be careful with the comparision operators. The tripple equal sign does not return true - what I
would expect when the type is both the same and the properties also contain the same values.
<?php
$date1 = new DateTime('2021-01-01');
$date2 = new DateTime('2021-01-01');
var_dump($date1 == $date2); // true
var_dump($date1 === $date2); // false
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 2003:ed:8f14:5ba:80e7:b377:4d4f:9b8d)
----
Manual Page -- https://php.net/manual/en/datetime.diff.php
Edit -- https://main.php.net/note/edit/129158
Del: integrated -- https://main.php.net/note/delete/129158/integrated
Del: useless -- https://main.php.net/note/delete/129158/useless
Del: bad code -- https://main.php.net/note/delete/129158/bad+code
Del: spam -- https://main.php.net/note/delete/129158/spam
Del: non-english -- https://main.php.net/note/delete/129158/non-english
Del: in docs -- https://main.php.net/note/delete/129158/in+docs
Del: other reasons-- https://main.php.net/note/delete/129158
Reject -- https://main.php.net/note/reject/129158
Search -- https://main.php.net/manage/user-notes.php