Why cannot the now () function display time?

Source: Internet
Author: User
{Code. However, after submission, only the date is available in the phpmyadmin database, and there is no time. the output is also like this -- {code ...} but executing selectnow () directly in it can get the current date and accurate time. Why can't I do it when I submit it?
$ Query = "insert into class (name, time) VALUES ('$ name', NOW ())";

Such a sentence. However, after submission, only the date is available in the phpmyadmin database, and there is no time. the output is also like this --

Tian2016-11-24tian2016-11-23tian2016-11-24tian2016-11-24tian2016-11-24

However, if you execute select now () directly in it, you can get the current date and accurate time. Why can't you do it when you submit it?

Reply content:
$ Query = "insert into class (name, time) VALUES ('$ name', NOW ())";

Such a sentence. However, after submission, only the date is available in the phpmyadmin database, and there is no time. the output is also like this --

Tian2016-11-24tian2016-11-23tian2016-11-24tian2016-11-24tian2016-11-24

However, if you execute select now () directly in it, you can get the current date and accurate time. Why can't you do it when you submit it?

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.