note 126896 added to class.datetime
| From: | florian dot c at main dot php dot net | Date: | Thu, 03 Mar 2022 16:10:56 +0000 |
| Subject: | note 126896 added to class.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217678@lists.php.net to get a copy of this message | ||
Be careful if you use the diff() method on PHP 8.1.0 and higher:
<?php
var_dump((new DateTime())->diff(new DateTime('-5 days'))->days);
// int(4) PHP > 8.1.0
// int(5) PHP < 8.1.0
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 193.251.76.109)
----
Manual Page -- https://php.net/manual/en/class.datetime.php
Edit -- https://main.php.net/note/edit/126896
Del: integrated -- https://main.php.net/note/delete/126896/integrated
Del: useless -- https://main.php.net/note/delete/126896/useless
Del: bad code -- https://main.php.net/note/delete/126896/bad+code
Del: spam -- https://main.php.net/note/delete/126896/spam
Del: non-english -- https://main.php.net/note/delete/126896/non-english
Del: in docs -- https://main.php.net/note/delete/126896/in+docs
Del: other reasons-- https://main.php.net/note/delete/126896
Reject -- https://main.php.net/note/reject/126896
Search -- https://main.php.net/manage/user-notes.php