views:

228

answers:

1

Does it use the server timezone or UNIX_TIMESTAMP (UTC) ?

And how do I get the current time in PHP, in the same timezone as MySQL's TIMESTAMP columns?

+4  A: 

Depends on your MySQL configuration variables, see MySQL Server Time Zone Support.

Alix Axel
That's the most generic answer you could think of! What is the default configuration, or how can I tell which one it is? server/unix timezone. I'm just a simple customer to hosting services so I don't really have full access to the MySQL configuration or installation.
Jenko
On my server MySQL uses a unix time but in the timezone of my server, I've verified this by modifying an `ON UPDATE CURRENT_TIMESTAMP` row quickly after running this PHP script `echo date('H:i:s', time());` and both return a time value that looks like they're both in the same timezone.
Jenko
@Jeremy Rudd: I'm sorry that you think my answer is too vague. By default MySQL uses the system timezone, but that may not always be the case (again depending on configuration variables, see `SET time_zone` and `SET GLOBAL time_zone`), it's always a good idea to issue this commands to make sure your application and database are running on the same time zone.
Alix Axel