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?

2
  • Please provide the error received from your error log. The code as provided is valid. Commented May 12, 2012 at 19:35
  • the solution could be in this link stackoverflow.com/questions/10841960/… Commented Sep 19, 2019 at 23:05

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks I found it out in the error log. I had to specifically set my timezone date_default_timezone_set('America/New_York');.
Can also set your default timezone in your PHP.ini file date.timezone

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.