我的产品有如下表格,paytime是varchar,addtime是int:
描述测试1;
+---------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+-------+
| paytime | varchar(30) | YES | | NULL | |
| addtime | int(10) unsigned | NO | | NULL | |
+---------+------------------+------+-----+---------+-------+
服务器a>选择版本();
+-----------------+
| version() |
+-----------------+
| 5.6.36-82.0-log |
+-----------------+
服务器b>选择版本();
+------------+
| version() |
+------------+
| 5.5.33-log |
+------------+
服务器a>从测试1的\u unixtime(paytime)和\u unixtime(addtime)中选择;
+----------------------------+------------------------+
| from_unixtime(paytime) | from_unixtime(addtime) |
+----------------------------+------------------------+
| 2018-01-18 01:56:12.000000 | 2018-01-18 01:56:12 |
+----------------------------+------------------------+
服务器b>从测试1的\u unixtime(paytime)和\u unixtime(addtime)中选择;
+------------------------+------------------------+
| from_unixtime(paytime) | from_unixtime(addtime) |
+------------------------+------------------------+
| 2018-01-18 01:56:12 | 2018-01-18 01:56:12 |
+------------------------+------------------------+
如您所见,当我使用from unixtime时,mysql 5.5返回'2018-01-18 01:56:12',mysql 5.6返回'2018-01-18 01:56:12',当参数是字符串类型时。有人知道原因吗?
1条答案
按热度按时间edqdpe6u1#
报告了一个与此行为相关的错误。
要解决问题直到bug被解决,一个解决方法是指定
datetime
在中显式格式化from_unixtime
```SELECT from_unixtime('1516240572', '%Y-%m-%d %H:%i:%s');
Output:- 2018-01-18 01:56:12