当我将数据从表导出到excel文件时,在日期部分,我将获得以下格式的日期加时间:
2016-09-02 00:00:00
但我希望日期部分只显示这样的日期,例如:
2016-09-02
没有时间。
这是我将表格数据导出到excel工作表的代码。
public function export_records(){
$date = Carbon::today()->toDateString();
$nc24_export = nc24form_model::where('created_at', '>=', Carbon::now()->subDays(7))->get();
Excel::create('Weekly Report' . $date , function($excel) use($nc24_export){
$excel->sheet('sheet 1', function($sheet) use($nc24_export){
$sheet->fromArray($nc24_export);
});
})->export('xlsx');
}
$sheet->setColumnFormat(['A'=>'@']);
试试