mysql时区问题

客户端连接时时区是根据当前连接session时区设置,并且只会影响函数和timestamp存取;时区设置不影响UTC_TIMESTAMP()函数和DATE、TIME、DATETIME数据列。

 

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

mysql> SET time_zone = timezone;

 

The current session time zone setting affects display and storage of time values that are zone-sensitive. This includes the values displayed by functions such as NOW() orCURTIME(), and values stored in and retrieved from TIMESTAMP columns. Values for TIMESTAMP columns are converted from the current time zone to UTC for storage, and from UTC to the current time zone for retrieval.

 

The current time zone setting does not affect values displayed by functions such as UTC_TIMESTAMP() or values in DATE, TIME, or DATETIME columns. Nor are values in those data types stored in UTC; the time zone applies for them only when converting from TIMESTAMP values. If you want locale-specific arithmetic for DATE, TIME, orDATETIME values, convert them to UTC, perform the arithmetic, and then convert back.

 

 

From: https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html

你可能感兴趣的:(Database)