Home  >  Article  >  Backend Development  >  关于MySQL中的now(),该如何解决

关于MySQL中的now(),该如何解决

WBOY
WBOYOriginal
2016-06-13 12:12:15977browse

关于MySQL中的now()
我用SQL在表中加入一组数据,date由now()取值。
代码如下:
INSERT INTO `inputtest`(`id`, `uid`, `content`, `date`) VALUES ("","Leo","Hello","now()")
代码运行:
8  Leo  Hello 0000-00-00 00:00:00

为什么now()的数值全是0000-00-00 00:00:00

------解决思路----------------------
设置时区了么?
------解决思路----------------------
修改一下 INSERT 语句:
INSERT INTO `inputtest`(`id`, `uid`, `content`, `date`) VALUES ("","Leo","Hello",now());

NOW()是函数,不用加引号,加了变成插入字符串,日期类型字段就会显示0000-00-00 00:00:00

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn