PHP date(/Datetime::W3C)插入日期格式提示错误_MySQL
select date('2014-05-16T11:13:57+08:00');
+-----------------------------------+
| date('2014-05-16T11:13:57+08:00') |
+-----------------------------------+
| 2014-05-16 |
+-----------------------------------+
1 row in set, 1 warning (0.02 sec)
mysql> select date('2014-05-16T11:13:57+08:00');
+-----------------------------------+
| date('2014-05-16T11:13:57+08:00') |
+-----------------------------------+
| 2014-05-16 |
+-----------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select date('2014-05-16T11:12:57+08:00');
+-----------------------------------+
| date('2014-05-16T11:12:57+08:00') |
+-----------------------------------+
| 2014-05-16 |
+-----------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select date_format('2014-05-16T11:13:57+08:00', '%Y-%m-%d %H:%i:%s');
+---------------------------------------------------------------+
| date_format('2014-05-16T11:13:57+08:00', '%Y-%m-%d %H:%i:%s') |
+---------------------------------------------------------------+
| 2014-05-16 11:13:57 |
+---------------------------------------------------------------+
1 row in set, 1 warning (0.03 sec)
mysql> select date_format('2014-05-16T11:13:57+08:00', '%Y-%m-%d %H:%i:%s');
+---------------------------------------------------------------+
| date_format('2014-05-16T11:13:57+08:00', '%Y-%m-%d %H:%i:%s') |
+---------------------------------------------------------------+
| 2014-05-16 11:13:57 |
+---------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
本人mysql版本是5.5.19,执行以上sql这个表明mysql是支持w3c日期格式的。
问题出在那儿呢?最后定位到了mysql可能开启严格检查日期模式,执行
set sql_mode=NO_ENGINE_SUBSTITUTION,这个问题就解决了!!!
不过mysql 重启后这个配置就失效了,最好的方法是修改mysql.ini制空
上一篇: 自定义session存储机制避免会话保持问题_php技巧
下一篇: 值得收藏的精致的动态祝福图片