错误日志:ISO 8601时间戳MySQL数据库:MySQL的不正确的时间值
{ [Error: Incorrect datetime value: '2012-08-24T17:29:11.683Z' for column 'robot _refreshed_at' at row 1] number: 1292, sqlStateMarker: '#', sqlState: '22007', message: 'Incorrect datetime value: \'2012-08-24T17:29:11.683Z\' for column \' robot_refreshed_at\' at row 1', sql: 'INSERT INTO users (id,name,count_moments,count_likes,count_followers,rob ot_refreshed_at,robot_count_followers) VALUES (\'1834084\',\'NNNyingzi\',\'5\',\ '0\',\'0\',\'2012-08-24T17:29:11.683Z\',\'0\')', setMaxListeners: [Function], emit: [Function], addListener: [Function], on: [Function], once: [Function], removeListener: [Function], removeAllListeners: [Function], listeners: [Function] }
我使用这段代码在我Node.js
if s instanceof Date
return s.toISOString()
并在数据库中更新它们。
的SQL
插入表达如下:
INSERT INTO users (id,name,count_moments,count_likes,count_followers,rob ot_refreshed_at,robot_count_followers) VALUES (\'1834084\',\'NNNyingzi\',\'5\',\ '0\',\'0\',\'2012-08-24T17:29:11.683Z\',\'0\')
难道我做错了什么?我刚刚从服务器中的表中使用PHPMyAdmin
复制了一张表。
非常感谢。
它是否改变了不同版本的'MySQL'的?我确信在我复制表的服务器上运行正常。 –
@ComboZhc:不是我的知识。也许PHPMyAdmin以这种方式格式化输出以显示,但格式不是有效的MySQL日期时间文字。如果需要,您可以使用['STR_TO_DATE()'](http://dev.mysql.com/doc//en/date-and-time-functions.html#function_str-to-date)执行转换。 – eggyal
如果在使用毫秒和/或微秒设置日期时遇到问题,可以禁用mysql严格模式(set sql_mode ='') – momo