Bug #68669 [Com]: DateTime::createFromFormat() does not allow NULL $timezone
| From: | christophe at gesche dot org | Date: | Mon, 20 Apr 2015 07:06:04 +0000 |
| Subject: | Bug #68669 [Com]: DateTime::createFromFormat() does not allow NULL $timezone | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192227@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68669&edit=1
ID: 68669
Comment by: christophe at gesche dot org
Reported by: ocramius at gmail dot com
Summary: DateTime::createFromFormat() does not allow NULL
$timezone
Status: Assigned
Type: Bug
Package: Date/time related
PHP Version: 5.6.4
Assigned To: neeke
Block user comment: N
Private report: N
New Comment:
idem with ubuntu & php 5.5.9
Previous Comments:
------------------------------------------------------------------------
[2014-12-28 22:31:38] ocramius at gmail dot com
Description:
------------
DateTime::createFromFormat($format, $time, DateTimeZone $timezone = null) has a default
value for its third parameter $timezone, but it doesn't accept null
as a value.
Running the following script will raise a warning:
DateTime::createFromFormat('Y/m/d', '2015/1/1', null);
// Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, null given
While the documentation states that the default timezone is going to be used when no parameter is
given, also the case where a null $timezone is given should be handled
correctly.
This would align the API to the language semantics about default values.
Test script:
---------------
<?php
var_dump(get_class(DateTime::createFromFormat('Y/m/d', '2015/1/1', null)));
Expected result:
----------------
string(8) "DateTime"
Actual result:
--------------
Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, null given in %a on
line 3
Warning: get_class() expects parameter 1 to be object, boolean given in %a on line 3 bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68669&edit=1