note 119053 deleted from datetimeimmutable.createfrommutable by peehaa

From: Date: Fri, 09 Dec 2016 22:38:55 +0000
Subject: note 119053 deleted from datetimeimmutable.createfrommutable by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208370@lists.php.net to get a copy of this message
Note Submitter: max ---- 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()); ?>

« previous php.notes (#208370) next »