I have centos server and i rechanged the time to NewYork time by date cmd. Also i change in php.ini the "date.timezone = "America/New_York"" When i enter the command date in the command shell. i get the real time in new york. But when I do
echo date("Y-m-d H:i:s");
The time isn't right! I always get 6 hours less then the time in New York. Please help? I tried already using date_default_timezone_set('America/New_York'); in the code with no help. waiting for a response. Thanks! Koren Or
You can initialize the timezone in your app. What happens when you do this?
Look, it is very common fault of people who aren't familiar with a formal logic.
Let me show you using a little example:
Suppose you just put some money into your pocket.
I come across and asks you if you got any money in your pocket. You says "Yes".
But you can't say it for sure! You can tell for sure only that you put it there. But there can be a hole in the pocket or some thief picked it already or you just confused pockets. So, you have to check it first, and answer later.
Although it is negligible in the real world, in programming such a behavior become critical! You can change whatever settings but you have to verify, if your actions had any effect
There can be an apache reload issue, or wrong ini.file or some runtime setting overwriting it.
Tl:dr
Always verify your settings, variables, data - if it really contains expected value!
Do not rely on the fact you changed it somewhere.
The date command doesn't provide a means to change the timezone. You probably set it to the time that it is in new york time, but as whatever timezone it was already set to, so you ended up with the server time being six hours off (odd, it should be five off if it's UTC).
Set the TZ environment variable
export TZ=America/New_York
before setting the time with the date command. Having an incorrect server time can lead to serious problems.I'm just guessing here but do you restarted your apache server?
This sounds like an issue with not actually setting the timezone correctly on your machine.
First, to verify PHP is using the correct timezone, try the following to see.
That should give you "America/New York" if you have set it correctly in your script.
If so, I would try the procedure discussed here to change the time on your system and see if that works.