Is PHP DateTime::RFC3339_EXTENDED broken?

As CBroe noted, this is the right solution for you. You should use Y-m-d\TH:i:s.uP instead of DateTime::RFC3339_EXTENDED, which is Y-m-d\TH:i:s.vP:

$date = DateTime::createFromFormat("Y-m-d\TH:i:s.uP", "2018-02-23T11:29:16.434Z"); //works

I actually went to take a look why this is happening, and here's what I found.

There is a closed bug requesting support for RFC3339 with milliseconds. The bug author created a pull request to add this feature. But whilst he created a RFC3339_EXTENDED constant for the format function, he did not add the support for createFromFormat. If you take a look here, there is no support for v option (which is milliseconds). So yeah.


Yes, apparently it only got fixed in PHP 7.3.0, see this https://3v4l.org/4nMi4

enter image description here