简体   繁体   中英

Changing set_timezone does not always take effect

I have two table

table-1

id  date-time
-----------------------
1   2012-12-13 15:20:13

table-2

id  date-time
-----------------------
1   2012-12-13 15:20:13

Now i am selecting the record with mysql set_timezone function

Case-1

SET time_zone='+00:00';
SELECT `date-time` FROM `table-1`;  // 2012-12-13 09:50:13

Case-2

SET time_zone='+00:00';
SELECT `date-time` FROM `table-2`;  // 2012-12-13 15:20:13 ---Not converting to specified timezone

In case-1 it's giving converted date-time, but not in Case-2. What would be the issue?

table-1

id  date-time
 -----------------------
 1   2012-12-13 15:20:13   // datatype->timestamp

table-2

id  date-time
-----------------------
1   2012-12-13 15:20:13  // datatype->datetime

So the issue was with datatype. Now i changed the datetime into timestamp in table-2. Issue solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM