我從dd-mm-yyyy格式的PHP窗體中獲取兩個日期。 (說01/06/2013和30/06/2013) 現在我使用下面的代碼來顯示上述日期範圍內的日期結果,但它不適合我,因爲存儲在數據庫中的日期在UNIX時間戳格式(transaction_date bigint(12)
)。我應該如何顯示日期結果呢?任何人都可以幫助我解決這個問題嗎?當日期是UNIX時間戳格式時如何按日期對記錄進行分組?
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();
}
在此先感謝。
我只是想這個你快一點 – Sundar