我正在尝试在模型中使用$casts
以特定格式在laravel中显示日期,但是当我在视图中显示时会出现错误
调用未定义的方法DateTime :: getTimezone()
我不知道为什么会出现此错误。
型号
class Category extends Model
{
use SoftDeletes;
protected $dates = [ 'created_at','updated_at','deleted_at'];
protected $casts = [
'created_at' => 'datetime:d-M-Y H:i:s',
'updated_at' => 'datetime:d-M-Y H:i:s',
'deleted_at' => 'datetime:d-M-Y H:i:s'
];
在我看来
<td>{{$model->created_at }}</td>
<td>{{$model->updated_at }}</td>
<td>{{$model->deleted_at }}</td>
Laravel 5.6