The following is a timestamp query. If the database time displays 2011-04-05, then there is no need to use the strtotime timestamp conversion function:
$timea = strtotime($_POST['timea']);
$timeb = strtotime($_POST['timeb']);
$sq2="select * from `ecs_order_info` where add_time between '$timea' and '$timeb' and `quanxian`='$ dangqian' order by `order_id` DESC limit 50";
$sql = mysql_query($sq2);
Extended information
Complete in php
p>1. Use function to convert UNIX timestamp to date: date()
General form: date('Y-m-d H:i:s', 1156219870);
2. Use the function to convert date to UNIX timestamp: strtotime()
General form: strtotime('2010-03-24 08:15:42');
In MySQL Complete
This method is converted in the MySQL query statement. The advantage is that it does not take up the parsing time of the PHP parser and is fast. The disadvantage is that it can only be used in database queries and has limitations.
1. Function to convert UNIX timestamp to date: FROM_UNIXTIME()
General form: select FROM_UNIXTIME(1156219870);
2. Convert date to UNIX Timestamp function: UNIX_TIMESTAMP()
General form: Select UNIX_TIMESTAMP('2006-11-04 12:23:00′);
Example: mysql query the number of records for the day :
$sql=”select * from message Where DATE_FORMAT(FROM_UNIXTIME(chattime),'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-% d') order by id desc".