Bug #78203 [Com]: date_create function behaves weird if the argument is "a string"
| From: | lol at reddit dot com | Date: | Mon, 02 Sep 2019 11:18:06 +0000 |
| Subject: | Bug #78203 [Com]: date_create function behaves weird if the argument is "a string" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222520@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78203&edit=1
ID: 78203
Comment by: lol at reddit dot com
Reported by: masergiu at gmail dot com
Summary: date_create function behaves weird if the argument
is "a string"
Status: Open
Type: Bug
Package: Date/time related
Operating System: any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is lolphp.
Previous Comments:
------------------------------------------------------------------------
[2019-06-25 07:02:32] masergiu at gmail dot com
Description:
------------
DateTime::__construct and its alias, date_create function, are returning weird results for the
following cases:
1. date_create('test') => returns false, which is expected according to documentation;
2. date_create('a test') => retuns the DateTime object constructed as "new
DateTime('now')", which is not expected.
Same is valid for new DateTime() process:
1. new DateTime('test') => throws Exception, which is expected according to
documentation;
2. new DateTime('a test') = retuns the DateTime object constructed as "new
DateTime('now')", which is not expected.
Test script:
---------------
php -r "var_dump(date_create('test')); // EXPECTED result"
php -r "var_dump(date_create('a test')); // UNEXPECTED result"
Expected result:
----------------
For the script below it should return FALSE also:
php -r "var_dump(date_create('a test')); // UNEXPECTED result"
Actual result:
--------------
For the script below it returns DateTime object constructed as "new
DateTime('now')":
php -r "var_dump(date_create('a test')); // UNEXPECTED result"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78203&edit=1