这里我以CSV格式导出表格结果,我想格式化这样的日期列 2017-08-31,13:10:12
任何人都可以帮我修改这个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);
}
答案 0 :(得分:3)
Arsee,您最好尝试使用此查询SELECT DATE_FORMAT(FROM_UNIXTIME(
created_on ), '%e %b %Y') AS OrderDate,
答案 1 :(得分:1)
像这样更改您的查询
$ query =“SELECT DATE_FORMAT(created_on,'%Y-%m-%d,%H:%i:%s')AS OrderDate FROM transaction”;
注意:应删除订单日期之间的空格