我有这样的收藏集
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"
]
如何只参加“ 2018-05-28”?有人可以帮我解决这个问题吗?还是谢谢你
$collection_item->created_at->format('Y-m-d');
我更喜欢这个
$model_item->created_at->toDateString();
因为模态中位于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];