我在這裏導出爲CSV格式表的結果,我想格式化日期列這樣的事情2017年8月31日,13時10分12秒笨 - 導出表記錄到CSV與日期格式
有人幫我修改這個MySQL查詢
$query = "SELECT DATE_FORMAT(created_on,'%Y-%m-%d , %H:%i:%s') AS OrderDate,transaction.order_id,transaction.payment_method FROM transaction";
,這裏是我的導出爲CSV功能
function ExportCSV()
{
$this->load->dbutil();
$this->load->helper('file');
$this->load->helper('download');
$delimiter = ",";
$newline = "\r\n";
$filename = "lugmah_sales_report.csv";
$query = "SELECT DATE_FORMAT(created_on,'%Y-%m-%d , %H:%i:%s') AS OrderDate,transaction.order_id,transaction.payment_method FROM transaction";
$result = $this->db->query($query);
$data = $this->dbutil->csv_from_result($result, $delimiter, $newline);
force_download($filename, $data);
}
https://dev.mysql.com/doc/refman/5.5/en/date -and-time-functions.html#function_date-format – rtfm
[MySQL date format change]可能重複(https://stackoverflow.com/questions/21463001/mysql-date-format-change) – RealCheeseLord
@RealCheeseLord我檢查過查詢但在CSV/Excel文件中,日期列顯示空白值 – Arsee