我从 dd-mm-yyyy 格式的 PHP 表单中得到两个日期。(说 01/06/2013 和 30/06/2013)现在我使用以下代码在上面给出的日期范围内显示日期结果,但它对我不起作用,因为存储在 DB 中的日期在 UNIX 时间戳中格式(transaction_date bigint(12)
)。那我应该如何显示日期结果呢?谁能帮我解决这个问题?
if($form_data['from_date']!='' && $form_data['to_date']!='') {
$from_time = explode("/", $form_data['from_date']);
$to_time = explode("/", $form_data['to_date']);
$start_date = mktime( 0,0,0,$from_time[1],$from_time[0],$from_time[2] ) ;
$end_date = mktime( 23,59,59,$to_time[1],$to_time[0],$to_time[2] ) ;
$sql =" SELECT COUNT(*) `total count`, SUM(transaction_status = 'success') `success`, ";
$sql .=" SUM(transaction_status = 'inprocess') `inprocess`, SUM(transaction_status = 'fail') `fail`, ";
$sql .=" SUM(transaction_status = 'cancelled') `cancelled` FROM user_transaction ";
$sql .=" WHERE transaction_date >= '".$start_date."' AND transaction_date <= '".$end_date."' GROUP BY transaction_date ";
$this->mDb->Query( $sql);
$queryResult = $this->mDb->FetchArray();
}
提前致谢。