开发者

How do I set up my mysql session to be in a certain timezone?

I need to dynamically change the timezone for mysql sessions due to traversing multiple databases which have different time zones.

How do I setup mysql to be tiemzone based for all m开发者_开发百科ysql date related queries?


You can use SET TIME_ZONE to set your session to a specific UTC offset.

For example, I'm in UTC -05:00, but I can change to UTC like this:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2011-03-02 12:32:39 |
+---------------------+
1 row in set (0.00 sec)

mysql> set time_zone = '+00:00';
Query OK, 0 rows affected (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2011-03-02 17:32:45 |
+---------------------+
1 row in set (0.00 sec)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜