0

I am using IST in my code. for this thing I declared gloabal variable as below code

date_default_timezone_set('Asia/Kolkata');
$IST=date('Y-m-d H:i:s');
$config['IST']=$IST;

In my other files I am calling this variable as

$IST = $config['IST'];
$time = $IST;
echo " Current time is $time";

I am getting wrong time. If current time is 2015-02-03 15:41:14 it is showing 2015-02-03 16:41:14

How to fix this issue?

I have updated my server time zone to Asia/Kolkata.

3
  • check what timezone you getting on other file? Commented Feb 3, 2015 at 10:18
  • Check out if your source works on other servers.. here a sample on IDEONE Commented Feb 3, 2015 at 10:23
  • @Dwza : Thanks for your suggestion. I found that my code is working on the other server. I found issue with server's clock. Commented Feb 3, 2015 at 13:13

3 Answers 3

1

'Asia/Kolkata' exists only since PHP 5.2.6. Which PHP version are you using ?

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

Comments

0

Try using date_default_timezone_set('Asia/Calcutta');

Comments

0

Thanks everyone for your valuable suggestions. I apologize. I did't check my server's clock. It was all about server's clock. Once I set my server's clock to correct time, issue resolved.

I apologize again and thanks again.

Comments

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.