我有一个AngularJS客户端,nodeJS服务器和一个MySQL数据库。
我正在尝试删除表的条目,当时间戳是用户电子邮件的主键时。
JSON从DB中提供了这些数据:
[{"instanceTime":"2018-02-10T14:19:29.000Z","item":"write papter","email":"admin@gmail.com","ischeck":0},
{"instanceTime":"2018-02-10T14:19:33.000Z","item":"paint chair","email":"admin@gmail.com","ischeck":0},
{"instanceTime":"2018-02-10T15:07:34.000Z","item":"yes","email":"admin@gmail.com","ischeck":0}]
但是使用此“instanceTime”删除会出错:
DELETE FROM tododb.taskstable WHERE (instanceTime like '2018-02-10T15:07:34.000Z' AND email like 'admin@gmail.com' );
errError: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: '2018-02-10T15:07:34.000Z' for column 'instanceTime' at row 1
为什么以这种方式形成“2018-02-10T14:19:29.000Z”? 当我使用时:
DELETE FROM taskstable
WHERE (instanceTime like "2018-02-10 14:19:29" AND email like "admin@gmail.com");
一切正常
答案 0 :(得分:0)
我做了两件事来解决这个问题。
插入taskstable 值(UNIX_TIMESTAMP(NOW()),"调用mom"," admin@gmail.com" ;, false);
UNIX时间戳更易于管理,因为它只是倒计时。
{{t.instanceTime * 1000 |日期:' yyyy-MM-dd HH:mm:ss'}}
不完全是我的要求,但我发现这更容易。