Why can't the now() function display the time?

WBOY
Release: 2023-03-01 19:56:02
Original
3225 people have browsed it

<code>    $query = "INSERT INTO class (name,time) VALUES ('$name', NOW())";</code>
Copy after login
Copy after login

Such a sentence. But after submission, there is only date and no time in the phpmyadmin database, and the output looks like this——

<code>tian
2016-11-24
tian
2016-11-23
tian
2016-11-24
tian
2016-11-24
tian
2016-11-24</code>
Copy after login
Copy after login

But you can get the current date and accurate time by executing select now() directly inside. Why can’t it work when submitting?

Reply content:

<code>    $query = "INSERT INTO class (name,time) VALUES ('$name', NOW())";</code>
Copy after login
Copy after login

Such a sentence. But after submission, there is only date and no time in the phpmyadmin database, and the output looks like this——

<code>tian
2016-11-24
tian
2016-11-23
tian
2016-11-24
tian
2016-11-24
tian
2016-11-24</code>
Copy after login
Copy after login

But you can get the current date and accurate time by executing select now() directly inside. Why can’t it work when submitting?

Please check whether the time field in your table is set to Datetime. If it is set to Date or char(10), it will be truncated due to incorrect format or length.

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