php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65502 DateTimeImmutable::createFromFormat returns DateTime
Submitted: 2013-08-22 11:27 UTC Modified: -
From: carlos at encore-lab dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.5.2 OS: CentOS 6.4 i386
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: carlos at encore-lab dot com
New email:
PHP Version: OS:

 

 [2013-08-22 11:27 UTC] 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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-12 13:23 UTC] nikic@php.net
Automatic comment on behalf of bsitnikovski@sugarcrm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=165f544ae9a3ac674a533a45ad8a8d5dccfa2536
Log: Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime
 [2013-09-12 13:23 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of bsitnikovski@sugarcrm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=165f544ae9a3ac674a533a45ad8a8d5dccfa2536
Log: Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 02 01:01:29 2025 UTC