note 128761 added to datetime.createfromformat
| From: | 8ctopus at main dot php dot net | Date: | Thu, 27 Jul 2023 06:10:06 +0000 |
| Subject: | note 128761 added to datetime.createfromformat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220722@lists.php.net to get a copy of this message | ||
Beware as there is no date validation as I would have expected for obviously invalid dates.
```
$date = '2023-23-05 22:05:02';
$format = 'Y-m-d H:i:s';
$date = DateTime::createFromFormat($format, $date);
if ($date === false) {
throw new Exception('invalid date format');
}
print_r(DateTimeImmutable::getLastErrors());
```
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 176.204.66.23)
----
Manual Page -- https://php.net/manual/en/datetime.createfromformat.php
Edit -- https://main.php.net/note/edit/128761
Del: integrated -- https://main.php.net/note/delete/128761/integrated
Del: useless -- https://main.php.net/note/delete/128761/useless
Del: bad code -- https://main.php.net/note/delete/128761/bad+code
Del: spam -- https://main.php.net/note/delete/128761/spam
Del: non-english -- https://main.php.net/note/delete/128761/non-english
Del: in docs -- https://main.php.net/note/delete/128761/in+docs
Del: other reasons-- https://main.php.net/note/delete/128761
Reject -- https://main.php.net/note/reject/128761
Search -- https://main.php.net/manage/user-notes.php