Reputation: 506
My server is in Los Angeles but I want my CURRENT_TIMESTAMP to be GMT. Can I set this automatically or should I send the GMT value to the insert or update statement?
Upvotes: 3
Views: 2434
Reputation: 1390
You straight away look at Php date method.
It is exactly what you need.
$timestamp = 67427423473;
echo date('M d Y H:i:s O', $timestamp)
Upvotes: 0
Reputation: 163488
See the documentation on this here: http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html
It seems that you can do a SET time_zone = YOURTIMEZONEGOESHERE;
and then the value of NOW() (which is equivalent to CURRENT_TIMESTAMP will be affected.
Of course, your server really should be set to UTC anyway. Let your code handle the offsets.
Upvotes: 0
Reputation: 52372
Set the time zone of the server to GMT, set the time zone of the MySQL server to GMT in its my.cnf configuration file, or set the time zone of the MySQL connection using a SET query before you run any other queries. However you go about it, you don't need to do it yourself in every query.
http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html
Your server really doesn't know it's in Los Angeles. It's just been TOLD to use the Pacific time zone.
Upvotes: 1