The previous example will not properly work.
<?php
DateTimeImmutable::createFromFormat('U', $date->getTimestamp(), $date->getTimezone());
?>
will always return a DateTimeImmutable object with a GMT timezone. createFromFormat seems to prefer the format to get the timeZone instead of the passed in timeZone.
This will work, but it is clunky:
<?php
$datei = DateTimeImmutable::createFromFormat('U', $date->getTimestamp(), $date->getTimezone());
$datei = $datei->setTimezone($date->getTimezone());
?>