A problem occurs when the input time of the DATE function is passed to the database! Expert guide

Source: Internet
Author: User
A problem occurs when the input time of the DATE function is passed to the database! Expert guidance! A problem occurs when the input time of the DATE function is passed to the database! Expert guidance! & Nbsp; my code is as follows & nbsp; & lt ;? & Nbsp; $ date = date (& quot; Y-m-d & nbsp; H: an error occurs when the input time of the DATE function is passed to the database! Expert guidance!
A problem occurs when the input time of the DATE function is passed to the database! Expert guidance!

My code is as follows:

$ Date = date ("Y-m-d H: I: s ");
$ Conn = new mysqli ('localhost', 'root', '123', 'time ');
If (mysqli_connect_errno ()){
Echo 'cannot connect to the database. ';
Exit ();
}
Echo $ date;
$ Query = "insert into time values (null, $ date )";
$ Re = $ conn-> query ($ query );
If (! $ Re ){
Echo 'failed to input data! ';
Exit ();
}
Echo 'successfully ';
$ Conn-> close ();
?>

Always show failed

Error message:
Debug Strict (PHP 5): C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs \ timetest. php line 2-date () [function. date]: It is not safe to rely on the system's timezone settings. please use the date. timezone setting, the TZ environment variable or the date_default_timezone_set () function. in case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. we selected 'utc' for '8. 0/no DST 'Instead

Thank you for your advice!

------ Solution --------------------
Date_default_timezone_set ('prc ');
$ Date = date ("Y-m-d H: I: s ");
...
Try it

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.