开发者

Mysql locale session variable?

开发者 https://www.devze.com 2022-12-26 15:55 出处:网络
Hunting internationalizati开发者_Python百科on bugs here. Does mysql has a variable which can be set per session, meaning the each connection will know the timezone of it\'s client and will act upon t

Hunting internationalizati开发者_Python百科on bugs here.

Does mysql has a variable which can be set per session, meaning the each connection will know the timezone of it's client and will act upon that.

If such variable does exists I would expect sql statements such as the following will return diffect values, based on connection session locale.

select date('2010-04-14') + 0;

Thank you, Maxim.


The DATE() function in MySQL returns server time unless you specify the timezone.

CONVERT_TZ() is useful. Let the user pick their time zone and store it on the server, then convert the date columns to the user's time.

There is a time_zone system variable that you can set for a session, which defaults to "SYSTEM".

Use SET @@variable to set the value.

For example:

SET @@time_zone = 'GMT';

However, the server doesn't automatically set this based on the location or timezone of the client.

0

精彩评论

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

关注公众号