1

I'm trying to convert time of a time zone to time for another time zone as provided in How can I easily convert dates from UTC via PHP? as provided below.

$dateTime = new DateTime("2009-04-01 15:36:13");
$dateTime->setTimezone(new DateTimeZone('Asia/Kolkata'));
echo $dateTime->format("Y-m-d H:i:s");

While testing at localhost, this seems to work fine but on my development server, the page throws a 500 internal server error (if called through ajax) or the page simply breaks from that line of code onwards.

Both localhost and my development server is using PHP 5.3.5.

Is there any reason why this would not be working?

Community
  • 1
  • 1
ptamzz
  • 9,235
  • 31
  • 91
  • 147

1 Answers1

9

Check the apache error log, that should contain the exact error you get. Everything else is just wild guessing :D

Niko Sams
  • 4,304
  • 3
  • 25
  • 44
  • 4
    Thanks I found it out in the error log. I had to specifically set my timezone `date_default_timezone_set('America/New_York');`. – ptamzz May 12 '12 at 19:35
  • 1
    Can also set your default timezone in your PHP.ini file [date.timezone](http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone) – codemonkee May 12 '12 at 19:39