Convert date from one timezone to another timezone PHP

This example is from phone call history 

//set default time zone
date_default_timezone_set('America/New_York');

//Set call date and time
$call_date = new DateTime(date("d-m-Y H:i:s", strtotime($call['calldate']." ".$call['calltime'])));

//Create new time zone object
$la_time = new DateTimeZone('Europe/London');

//Set time zone to date
$call_date->setTimezone($la_time);

//show new date and time
echo $call_date->format('d-m-Y');
echo $call_date->format("H:i:s");

Chamath Gunasekara

Comments

Popular posts from this blog

Laravel Sail on Windows issue - "cmdlet Invoke-WebRequest at command pipeline position 1"

GIT Error: The following untracked working tree files would be overwritten by merge:

How to point Magento multi websites to domains