Home > Backend Development > PHP Tutorial > 关于MySQL中的now()

关于MySQL中的now()

WBOY
Release: 2016-06-23 13:42:52
Original
1251 people have browsed it

我用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

修改一下 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