note 130618 added to function.date
| From: | Anonymous | Date: | Wed, 21 Jan 2026 07:52:19 +0000 |
| Subject: | note 130618 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-222509@lists.php.net to get a copy of this message | ||
Be careful as this innocent piece of code
<?php
echo date('d.m.Y', null);
?>
outputs a different date on PHP 8 vs. earlier.
In PHP 8
null is treated as null and will make date() use its
default value.
While on earlier PHP versions null will be cast to 0 therefore outputing
01.01.1970 (Unix Epoc)
----
Server IP: 206.189.2.9
Probable Submitter: 80.221.240.179
----
Manual Page -- https://php.net/manual/en/function.date.php
Edit -- https://main.php.net/note/edit/130618
Del: integrated -- https://main.php.net/note/delete/130618/integrated
Del: useless -- https://main.php.net/note/delete/130618/useless
Del: bad code -- https://main.php.net/note/delete/130618/bad+code
Del: spam -- https://main.php.net/note/delete/130618/spam
Del: non-english -- https://main.php.net/note/delete/130618/non-english
Del: in docs -- https://main.php.net/note/delete/130618/in+docs
Del: other reasons-- https://main.php.net/note/delete/130618
Reject -- https://main.php.net/note/reject/130618
Search -- https://main.php.net/manage/user-notes.php