MySQL 一处诡异的问题

皮总 发布于 2013/04/24 18:02
阅读 261
收藏 0
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2488
Server version: 5.5.24 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT STR_TO_DATE('19910415', '%Y%m%d') ,UNIX_TIMESTAMP(STR_TO_DATE('19910415', '%Y%m%d')) AS TRADING_DATE;
+-----------------------------------+--------------+
| STR_TO_DATE('19910415', '%Y%m%d') | TRADING_DATE |
+-----------------------------------+--------------+
| 1991-04-15                        |    671641200 |
+-----------------------------------+--------------+
1 row in set (0.02 sec)

mysql> SELECT STR_TO_DATE('19910414', '%Y%m%d') ,UNIX_TIMESTAMP(STR_TO_DATE('19910414', '%Y%m%d')) AS TRADING_DATE;
+-----------------------------------+--------------+
| STR_TO_DATE('19910414', '%Y%m%d') | TRADING_DATE |
+-----------------------------------+--------------+
| 1991-04-14                        |    671558400 |
+-----------------------------------+--------------+
1 row in set (0.00 sec)


671641200 - 671558400 = 82800

82800 = 23小时
加载中
0
开源中国董事会主席
开源中国董事会主席
我第一条 SQL 语句得到的 TRADING_DATE 结果: 671644800
皮总
皮总
难道是 5.5.24 的 BUG ?
0
deleted
deleted

不是bug

首先你选了一个好日子, 国内就用过几个夏令时段, 91年4月14号正好是其一, 这天只有23小时....接着你又没有set time_zone使用GMT,  mysql调用了你系统设置的CST时区....然后这一天就真的只有23小时了.....

八宝旗
八宝旗
mark
返回顶部
顶部