PHP Datetime ISO8601转换

I'm formatting a date in ISO8601 with Datetime and then i restore it, but restoring don't give me original value.

Test snippet

$d = new \DateTime('0000-00-00 00:00:00');
$formatted =  $d->format(\DateTime::ISO8601);
$restored  =  \DateTime::createFromFormat(\DateTime::ISO8601, $formatted);
var_dump($d);
var_dump($formatted);
var_dump($restored);

Result

object(DateTime)[5]
  public 'date' => string '-0001-11-30 00:00:00' (length=20)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Rome' (length=11)

string '-0001-11-30T00:00:00+0100' (length=25)


boolean false

PHP version PHP 5.4.28

0th of Nulluary is not a date that exists. PHP does some time math with it (e.g. the 13th month becomes the 1st month of the following year, values <1 work the other way backwards), so you get what you get. There is no "right" answer for 0000-00-00, it's nonsense. It works fine with real dates.