Bug #78203 [NEW]: date_create function behaves weird if the argument is "a string"
| From: | masergiu at gmail dot com | Date: | Tue, 25 Jun 2019 07:02:32 +0000 |
| Subject: | Bug #78203 [NEW]: date_create function behaves weird if the argument is "a string" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221471@lists.php.net to get a copy of this message | ||
From: masergiu at gmail dot com
Operating system: any
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:date_create function behaves weird if the argument is "a string"
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 bug report at https://bugs.php.net/bug.php?id=78203&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78203&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78203&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78203&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78203&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78203&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78203&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78203&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78203&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78203&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78203&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78203&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78203&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78203&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78203&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78203&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78203&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78203&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78203&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78203&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78203&r=mysqlcfg