Can anyone suggest an easy method to convert date and time to different timezones in php?
DateTime::setTimezone -- date_timezone_set — Sets the time zone for the DateTime object
Object oriented style
format('Y-m-d H:i:sP') . "\n";
$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format('Y-m-d H:i:sP') . "\n";
?>
Procedural style
The above examples will output:
2000-01-01 00:00:00+12:00
2000-01-01 01:45:00+13:45