I want to convert date time from the timezone UTC to any timezone like UTC+01 and also like timezone name e.g. Asia/Calcutta.
How can I do this?
Here is my code
<?php
date_default_timezone_set("UTC");
$date = new DateTime(date("Y-m-d H:i:s"));
$date->setTimezone(new DateTimeZone('UTC+01'));
echo $date->format('Y-m-d H:i:s');
?>
I am getting the following error :
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (UTC+01)' in /var/www/html/test/index.php:6 Stack trace: #0 /var/www/html/test/index.php(6): DateTimeZone->__construct('UTC+01') #1 {main} thrown in /var/www/html/test/index.php on line 6