MySQL Timezones

MySQL’s DATETIME and TIMESTAMP datatype do NOT include timezones. However TIMESTAMP columns are sensitive to MySQL’s current timezone. It’s especially important to note that DATETIME, DATE, and TIME are NOT sensitive to MySQL’s current timezone. Also, certain functions are sensitive to timezone and others are not.

Datatype Sensitive to timezone
TIMESTAMP Yes
DATETIME No
DATE No
TIME No
Function Sensitive to timezone
NOW() Yes
CURTIME() Yes
UTC_TIMESTAMP() No
UNIX_TIMESTAMP() Yes

MySQL’s timezone is stored in time_zone. Use the following to discover it:

"SHOW VARIABLES LIKE 'time_zone'

It is possible to change the timezone for a session using the following syntax:

SET time_zone = '+0:00'

Even further, it’s possible to set the timezone globally using this syntax:

SET GLOBAL time_zone = '+0:00'

References


mysql

123 Words

2010-08-11 18:06 +0000