note 128260 added to datetime.examples-arithmetic
| From: | jayrobneto at gmail dot com | Date: | Mon, 27 Feb 2023 20:24:28 +0000 |
| Subject: | note 128260 added to datetime.examples-arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220218@lists.php.net to get a copy of this message | ||
You can compare DateTimeImmutable objects with the operators > and <.
I didn't find this answer readily available in the docs so I tested it out:
<?php
$today = new DateTimeImmutable('2023-02-27');
$tomorrow = new DateTimeImmutable('2023-02-28');
echo($today->format("Y-m-d"));
echo("\n");
echo($tomorrow->format("Y-m-d"));
echo("\n");
$comparable = ($today < $tomorrow)? "true" : "false";
echo ($comparable);
?>
will output:
2023-02-27
2023-02-28
true
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 2804:14d:8084:992b:388d:7e65:2e11:2336)
----
Manual Page -- https://php.net/manual/en/datetime.examples-arithmetic.php
Edit -- https://main.php.net/note/edit/128260
Del: integrated -- https://main.php.net/note/delete/128260/integrated
Del: useless -- https://main.php.net/note/delete/128260/useless
Del: bad code -- https://main.php.net/note/delete/128260/bad+code
Del: spam -- https://main.php.net/note/delete/128260/spam
Del: non-english -- https://main.php.net/note/delete/128260/non-english
Del: in docs -- https://main.php.net/note/delete/128260/in+docs
Del: other reasons-- https://main.php.net/note/delete/128260
Reject -- https://main.php.net/note/reject/128260
Search -- https://main.php.net/manage/user-notes.php