Laravel 数据表日期格式不起作用

2 php datatable laravel

我正在使用数据表来显示数据包含postingdate列,我需要更改postingdate列的格式,因为我找到了一些关于此的教程并在运行时使用了下面的代码。我收到错误消息,但没有出现表格。

错误信息:

数据表警告:表 id=users-table - Ajax 错误。有关此错误的更多信息,请参阅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);
Run Code Online (Sandbox Code Playgroud)

ore*_*pot 7

试试下面的代码:

$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);
Run Code Online (Sandbox Code Playgroud)