Create Immutable version of DateTime from Mutable prior PHP 5.6
suggest changeTo create \DateTimeImmutable
in PHP 5.6+ use:
\DateTimeImmutable::createFromMutable($concrete);
Prior PHP 5.6 you can use:
\DateTimeImmutable::createFromFormat(\DateTime::ISO8601, $mutable->format(\DateTime::ISO8601), $mutable->getTimezone());
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents