Convert Date and Time from One Time Zone to Another using PHP

DateTimeZone class

<?php

$dateTimeFormat = 'Y-m-d H:i:s';

$fromTz = new DateTimeZone('Europe/London');
$toTz = new DateTimeZone('America/New_York');

$fromDateTime = '2020-09-12 20:30:00';

$dt = new DateTime($fromDateTime, $fromTz);
$dt->setTimezone($toTz);

$toDateTime = $dt->format($dateTimeFormat);

echo $toDateTime;

Leave a Comment

Cancel reply

Your email address will not be published.