php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78778 DateTime constructor and createFromFormat behaves differently
Submitted: 2019-11-04 11:45 UTC Modified: 2020-01-20 17:11 UTC
From: boan at jfmedier dot dk Assigned: derick (profile)
Status: Verified Package: Date/time related
PHP Version: 7.2.24 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: boan at jfmedier dot dk
New email:
PHP Version: OS:

 

 [2019-11-04 11:45 UTC] boan at jfmedier dot dk
Description:
------------
I would expect that the factory method createFromFormat should work like the constructor parameter. 

Test script:
---------------
$date = new DateTimeImmutable('2019-11-01T12:12:40.8859136+00:00');

var_dump($date);

$date = DateTimeImmutable::createFromFormat(DateTimeInterface::RFC3339_EXTENDED, '2019-11-01T12:12:40.8859136+00:00');

var_dump($date);

Expected result:
----------------
object(DateTimeImmutable) {
  ["date"]=>
  string(26) "2019-11-01 12:12:40.885913"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "+00:00"
}

object(DateTimeImmutable) {
  ["date"]=>
  string(26) "2019-11-01 12:12:40.885913"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "+00:00"
}

Actual result:
--------------
object(DateTimeImmutable) {
  ["date"]=>
  string(26) "2019-11-01 12:12:40.885913"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "+00:00"
}

bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-04 11:57 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2019-11-04 11:57 UTC] cmb@php.net
Well, that doesn't look quite right: <https://3v4l.org/AADtE>.
 [2020-01-20 17:11 UTC] girgias@php.net
-Assigned To: +Assigned To: derick
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 24 21:01:26 2020 UTC