Alm*_*ody 4 php collections laravel php-carbon
我有这样的集合
0 => array:4 [
"so" => "SO-1"
"product_name" => "EXTREME FORTE - BP"
"created_at" => Carbon @1527481346 {#628
date: 2018-05-28 04:22:26.0 UTC (+00:00)
}
"id" => "5b0b84027475aa1508002623"
]
Run Code Online (Sandbox Code Playgroud)
怎么走"2018-05-28"呢?有人可以帮我解决这个问题吗?不管怎么说,还是要谢谢你
我更喜欢这个
$model_item->created_at->toDateString();
Run Code Online (Sandbox Code Playgroud)
因为位于protected $dates array模式中的所有日期字段都是\Carbon\Carbon.
因此,只要您$dates array在模态中将其声明为日期,上述代码就可以应用于任何日期字段,如下所示
// this includes created_at and updated_at by default so no need to add it
protected $dates = ['approved', 'seen_at'];
Run Code Online (Sandbox Code Playgroud)