Monday, May 14, 2012

MySQL timestamp not saving in GMT?

I'm using the timestamp data type in MySQL so that any timestamp saved will be converted into GMT, then back from GMT on retrieval. From the documentation, it seems like this is all automatically done for me by MySQL; all I need to do is use the timestamp data type.



However, I noticed that it doesn't seem to work. I've tested this on my local machine and server -- and it seems that it always saves the local time instead of GMT. The local machine and server are in different time zones and neither are in GMT.



Here's my test insert:



INSERT INTO `test` (`test_id`, `stamp`) VALUES (NULL, CURRENT_TIMESTAMP);


Any ideas what I'm doing wrong?





No comments:

Post a Comment