To create an order query interface, you need to retrieve the order for the current day. The data table contains only one order time field, which is saved in the timestamp format. Not in 2010-10-5 format. You can specify two time points for data query. Since there is only one pivot point, we have never done anything similar. When writing SQL queries. At first encountered a small obstacle.
To create an order query interface, you need to retrieve the order for the current day. The data table contains only one order time field, which is saved in the timestamp format. Not in 2010-10-5 format. You can specify two time points for data query. Since there is only one pivot point, we have never done anything similar. When writing SQL queries. At first encountered a small obstacle.
To create an order query interface, you need to retrieve the order for the current day. The data table contains only one order time field, which is saved in the timestamp format. Not in 2010-10-5 format. You can specify two time points for data query. Since there is only one pivot point, we have never done anything similar. When writing SQL queries. At first encountered a small obstacle.
According to my colleagues, they can all be converted to the format. The timestamp stored in the database is converted to this format. The year and day indicate the same day of the same year.
The above method can achieve the goal, but the workload is a little large. The starting point is: The timestamp of the database to be converted is in date format. As a friend reminded me, I thought of another idea: converting it into a unix timestamp for comparison. This makes it easier to write SQL queries. Simple. In the previous method, database functions are not only required for SQL writing. In addition, the php code still needs to be judged on the same year and the same day (the same year is required first; otherwise, the same day does not meet the requirements)
The code written at that time is as follows:
/*
* + -------------------------------
* Calculate the start and end timestamp of the current day to retrieve the data of the current day.
* + ------------------------------
*/
$ Year = date ("Y ");
$ Month = date ("m ");
$ Day = date ("d ");
$ DayBegin = mktime (, 0, $ month, $ day, $ year); // the start time of the day.
$ DayEnd = mktime (, 59, $ month, $ day, $ year); // end time stamp of the current day
$ Query = "SELECT * FROM 'fanli _ info' WHERE insert_time <$ dayEnd AND insert_time> $ dayBegin ";