The time format passed by the front end is "2016-07-11 11:13:10", and the format of the corresponding field ' Add_time ' in the datasheet is "2016-7-11", when SQL cannot be used directly with "where ' add_time ' = ' 2016-07-11 11:13:10 '. This can be done in the following ways:
1. Use PHP's Strtotime () and date () to format the data before it is used for SQL queries, to become the format that is ultimately needed, and then use the data for the query:
1 $t = ' 2015-03-02 12:04:12 '; 2 $t Date Strtotime ($t)); 3 Echo $t;
Input:
2016-07-11
2. You can use the MySQL keyword "like" + "%", where the section is as follows:
1 select * from Test where ' add_time ' like ' 2016-07-11% '
Note: Because '% ' is behind a string, the index can be used if an index is established on the ' Add_time ' field.
If there is any mistake, please correct me.
How to resolve query problems when the time format from the front end does not match the time format in the MySQL table