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: 2019-11-04 11:57 UTC
From: boan at jfmedier dot dk Assigned:
Status: Verified Package: Date/time related
PHP Version: 7.2.24 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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>.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 14:01:29 2019 UTC