Edit report at https://bugs.php.net/bug.php?id=65502&edit=1
ID: 65502 Updated by: ni...@php.net Reported by: carlos at encore-lab dot com Summary: DateTimeImmutable::createFromFormat returns DateTime -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: CentOS 6.4 i386 PHP Version: 5.5.2 Block user comment: N Private report: N New Comment: Automatic comment on behalf of bsitnikov...@sugarcrm.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=165f544ae9a3ac674a533a45ad8a8d5dccfa2536 Log: Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime Previous Comments: ------------------------------------------------------------------------ [2013-08-22 11:27:15] carlos at encore-lab dot com Description: ------------ --- >From manual page: http://www.php.net/datetimeimmutable.createfromformat --- According to the manual (and the common sense also), DateTimeImmutable::createFromFormat should return a DateTimeImmutable object, but instead of that it returns a DateTime one. Test script: --------------- I've used the CLI console to test it: php > $today = DateTimeImmutable::createFromFormat('Y-m-d|', '2013-08-22'); php > $tomorrow = $today->add(new DateInterval('P1D')); php > var_dump($today->format('Y-m-d'), $tomorrow->format('Y-m-d')); string(10) "2013-08-23" string(10) "2013-08-23" php > var_dump($today instanceof DateTimeImmutable); bool(false) php > var_dump($today instanceof DateTime); bool(true) Expected result: ---------------- $today must contain a DateTimeImmutable object and thus it must be immutable. Actual result: -------------- $today is a DateTime object instead of DateTimeImmutable ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65502&edit=1