php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76218 DateTime::createFromFormat should support 'v' (milliseconds)
Submitted: 2018-04-13 14:02 UTC Modified: 2018-04-13 14:48 UTC
From: giacomo dot pinato at gmail dot com Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 7.2.4 OS: MacOS
Private report: No CVE-ID: None
 [2018-04-13 14:02 UTC] giacomo dot pinato at gmail dot com
Description:
------------
The DateTime class fails to correctly instantiate with the DATE_RFC3339_EXTENDED when input data is correct.

The example in this bug is taken directly from the documentation at http://php.net/manual/en/class.datetime.php


Test script:
---------------
<?php
$willBeFalse = DateTime::createFromFormat(DATE_RFC3339_EXTENDED, '2005-08-15T15:52:01.000+00:00');

$willAlsoBeFalse = DateTimeImmutable::createFromFormat(DATE_RFC3339_EXTENDED, '2005-08-15T15:52:01.000+00:00');

$date = new DateTime();
$shouldNotBeFalse = DateTime::createFromFormat(DATE_RFC3339_EXTENDED, $date->format(DATE_RFC3339_EXTENDED));

var_dump($shouldNotBeFalse); // false

Expected result:
----------------
The two objects should get instantiated correctly

Actual result:
--------------
$willBeFalse and $willAlsoBeFalse are false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-13 14:12 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-04-13 14:12 UTC] requinix@php.net
The format string is "Y-m-d\TH:i:s.vP". I do not see 'v' listed as supported in the docs for createFromFormat.
Use DateTime::getLastErrors() to see the warnings.

What example did you see with that code?
 [2018-04-13 14:13 UTC] requinix@php.net
-Summary: Format DATE_RFC3339_EXTENDED fails to match valid input +Summary: DateTime::createFromFormat should support 'v' (milliseconds) -Status: Not a bug +Status: Open -Type: Bug +Type: Feature/Change Request
 [2018-04-13 14:48 UTC] salathe@php.net
-Status: Open +Status: Duplicate
 [2018-04-13 14:48 UTC] salathe@php.net
Duplicate of #75577.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC