laravel datatable更改日期格式 - Ajax错误

时间:2017-12-24 06:31:21

标签: php ajax laravel datatable

我尝试使用以下函数更改laravel datatable的日期格式,但它不起作用。

我收到以下错误消息:

  

DataTables警告:table 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);

我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

 $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('Y/d/m', strtotime($user->postingdate) );
      })->make(true);