MySQL - difference between CET and CEST
I need to move some tables from MySQL database to PostgreSQL. So i've checked, which time zone is MySQL server using by checking system variable:
system time zone CET
CET
- as far as i know - in contrast of CEST
- is never more than UTC+1
.
CEST
is in summer UTC+2
. According to http://en.wikipedia.org/开发者_如何学编程wiki/Central_European_Time
But SELECT CURRENT_TIMESTAMP()
actually returns CEST
time (UTC+2
):
Why?
So i've checked, which time zone is MySQL server using by checking system variable
How did you do this?
Try this query please and tell me the results:
SELECT @@global.time_zone, @@session.time_zone;
There can be three types of results.
- SYSTEM
which means, that MySQL uses the timezone settings of your OS
- something like '+01:00' or whatever value
which is the difference to the UTC (Coordinated Universal Time)
- something like 'Europe/Berlin'
which is basically the same as above, but you have populated your timezone tables in MySQL.
You see, datetime
values are stored as UTC value internally by MySQL.
So, when you insert '2011-03-30 12:34:56' in your table with the SYSTEM variable set to 'Europe/Berlin' / '+01:00', MySQL calculates the integer representation for '2011-03-30 11:34:56', saves the value in your DB. When you query for your datetime values, MySQL adds that hour again (assuming your timezone settings haven't changed) and presents you the value '2011-03-30 12:34:56'
精彩评论