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

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

WBOY
Release: 2016-06-13 12:12:15
Original
1043 people have browsed it

关于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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template