I want to get date in another timezone of the date in indian timezone in php. i.e. if the date is 01-02-2013 in indian (+5:30) timezone What is the date in antoher timezone. ?
Asked
Active
Viewed 182 times
-2
-
http://stackoverflow.com/search?q=%5Bphp%5D+DateTime+DateTimeZone – M8R-1jmw5r Apr 14 '13 at 09:32
2 Answers
1
Take a look at the DateTime and DateTimeZone objects.
<?php
$date = new DateTime('now', new DateTimeZone('Europe/London'));
echo $date->format('r e'); // Sun, 14 Apr 2013 10:24:55 +0100 Europe/London
$date->setTimezone(new DateTimeZone('America/New_York'));
echo $date->format('r e'); // Sun, 14 Apr 2013 05:26:08 -0400 America/New_York

Anthony Sterling
- 2,451
- 16
- 10
-
+1 I'll just add that according to a comment on the [manual pages](http://php.net/manual/en/timezones.indian.php) India itself is handled by the `Asia/Calcutta` timezone - you may be forgiven for thinking it would be somewhere in the `Indian/*` branch... – Emissary Apr 14 '13 at 09:34
0
Use date_default_timezone_set
: http://php.net/manual/en/function.date-default-timezone-set.php

alxgb
- 543
- 8
- 18
-
will date_default_timezone_set changes a given gate into new timezone ?? – Krishna Kishore Apr 14 '13 at 12:27
-
@KrishnaKishore You can: change timezone, calculate the date (Will give it in the timezone you set), and then go back to the old timezone if you want. – alxgb Apr 15 '13 at 05:35