MySQL datetime is 2 hours off?
I have a very strange problem that I can't wrap my head around... I have a PHP file which outputs this: date('Y-m-d H:i:s', time())
And it outputs the cor开发者_StackOverflowrect datetime. Then I try to save this into a MySQL datetime field (using Wordpress DB API, not that it matters) - but the time recorded in the database is two hours off! For example, it will say 2011-07-09 09:00:57, when it's supposed to be 2011-07-09 11:00:57.
Is there some separate time settings for mySQL or something that could cause this to happen? Can anyone think of reasons this might happen, and I will investigate it. I don't know what to look for right now.
You probably need to set the proper timezone in your MySQL server or your connection to that server.
log in your wp admin. then goto Settings > General.Then you can change Timezone settings
You can explicitly set the server time for mysql. http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html
精彩评论