Skip to content

Instantly share code, notes, and snippets.

View gist:807c2d409f9b12140159766d9c51cdeb
$wrongDate = new \DateTime('2018-04-25 16:00:00', new \DateTimeZone('+0300'));
// Wed, 25 Apr 2018 16:00:00 +0300
fixZone($wrongDate, new \DateTimeZone('UTC'));
// Wed, 25 Apr 2018 16:00:00 +0000
function fixZone(\DateTime $dateTime, DateTimeZone $rightZone)
{
$offset = $dateTime->getOffset();
$zoneOffset = $rightZone->getOffset($dateTime);