C. E.
C. E.

Reputation: 10607

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 correct 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.

Upvotes: 2

Views: 2352

Answers (3)

Gowri
Gowri

Reputation: 16835

log in your wp admin. then goto Settings > General.Then you can change Timezone settings

Upvotes: 0

madflow
madflow

Reputation: 8490

You can explicitly set the server time for mysql. http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html

Upvotes: 0

Wrikken
Wrikken

Reputation: 70490

You probably need to set the proper timezone in your MySQL server or your connection to that server.

Upvotes: 6

Related Questions