Laravel Datatable日期格式不起作用 [英] Laravel datatable date format doesn't work
本文介绍了Laravel Datatable日期格式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用数据表来显示包含postingdate
列的数据,我需要更改postingdate
列的格式,因为我找到了一些与此相关的教程,并在运行时使用了下面的代码.我收到错误消息,但表格未出现.
I'm using datatable to display data include postingdate
column, I need to change the format of postingdate
column, as I found some tutorials about this and used the code below put when run. I got error message and table doesn't appear.
错误消息:
DataTables警告:表id = users-table-Ajax错误.欲了解更多 有关此错误的信息,请参见 http://datatables.net/tn/7
DataTables warning: table id=users-table - Ajax error. For more information about this error, please see http://datatables.net/tn/7
代码:
$users = Checks::select(['details', 'postingdate', 'description', 'amount', 'type', 'slip', 'vendor_id', 'category_id']);
return Datatables::of($users)->editColumn('postingdate', function ($user) {
return $user->postingdate->format('d-m-Y')})->make(true);
推荐答案
尝试以下代码:
$users=Checks::select(['details','postingdate','description','amount','type','slip','vendor_id','category_id']);
return Datatables::of($users)->editColumn('postingdate', function ($user)
{
//change over here
return date('d-m-Y', strtotime($user->postingdate) );
})->make(true);
这篇关于Laravel Datatable日期格式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文