OK,
I have a problem. I'm setting up a site that will end up holding large amounts of client data records. Because the clients can export and import their data, I have to be able to maintain session based timezones with in the site and server.
Right now my server is set to GMT. When I run the date command on the shell I see, which is correct at time of posting.
Fri Mar 18 20:04:32 GMT 2011
Then when i do hwcloc开发者_开发百科k --show is gives me, again this is was correct.
Fri 18 Mar 2011 08:06:22 PM GMT
Now when i tell php to change it's timezone to GMT-4 (since that is my timezone factoring in DST)
date_default_timezone_set('Etc/GMT-4');
echo date("m/d/Y g:i:s A T");
I get 03/19/2011 00:11:35 AM GMT-5 Is is totally wrong in stead of taking 5 hours away it added 5 hours.
So then I did this:
date_default_timezone_set('Etc/GMT+4');
echo date("m/d/Y g:i:s A T");
I got 03/18/2011 4:14:56 PM GMT+4. Which is the correct time. MySQL does the same thing. It seems like both are wanting to invert the time adjustments. Am i missing something on the settings?
No I think you misunderstand the notation/syntax.
The idea is that you set +
if the timezone you want to get to is west of prime meridian, and you set -
it it is east of it. So it doesn't actually have anything to do with the number of hours you add or take away, rather, to go back to the example, GMT+4:
4 hours in countries that are west of Greenwich
Which is basically the eastern edge of the USA, who are a few hours behind us in England... thinking about it this way should make sense.
精彩评论