Setting the session time zone in MySQL


Can someone explain to me why the following happens?

I have a table ‘test’ with one column named ‘test’ that has type DATETIME. It contains one record. If I open MySQL workbench and execute the following:

SET time_zone = '+00:00';
UPDATE test SET test = '2010-12-08 09:00:00';
SELECT @@session.time_zone, test FROM test;
SET time_zone = '+01:00';
SELECT @@session.time_zone, test FROM test;

This is the result:
‘+00:00’, ‘2010-12-08 09:00:00’
‘+01:00’, ‘2010-12-08 09:00:00’

I don’t understand why the second result isn’t:
‘+01:00’, ‘2010-12-08 10:00:00’

I need to set the timezone per session so that my code has the same timezone as my MySQL connection.


I found out that DATETIME columns do not take timezones into account, but merely represent sort of a string in date format. This poses another problem regarding daylight saving time: these can’t be represented using DATETIME columns. I therefor converted these columns to TIMESTAMP and that works.