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?
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.
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.
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)
Use:
UTC_TIMESTAMP
Instead of:
CURRENT_TIMESTAMP
精彩评论