Bug #68669 [Opn->Asn]: DateTime::createFromFormat() does not allow NULL $timezone

From: Date: Tue, 10 Mar 2015 15:43:38 +0000
Subject: Bug #68669 [Opn->Asn]: DateTime::createFromFormat() does not allow NULL $timezone
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191291@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 Updated by: neeke@php.net Reported by: ocramius at gmail dot com Summary: DateTime::createFromFormat() does not allow NULL $timezone -Status: Open +Status: Assigned Type: Bug Package: Date/time related PHP Version: 5.6.4 -Assigned To: +Assigned To: neeke Block user comment: N Private report: N 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

« previous php.bugs (#191291) next »