Php Laravel使用Carbon::today如何从datetime字段获取日期值?
这是我的控制器代码。如何从datetime字段中获取日期值Php Laravel使用Carbon::today如何从datetime字段获取日期值?,php,laravel,date,datetime,Php,Laravel,Date,Datetime,这是我的控制器代码。如何从datetime字段中获取日期值 public function UserContentShowDateList(){ 'usercontents'=>UserContent::where('status',1 )->where('date', Carbon::today())->get() } 我认为这将有助于仅从datetime字段获取日期。您可以使用whereDate UserContent::where('status',1 )->wh
public function UserContentShowDateList(){
'usercontents'=>UserContent::where('status',1 )->where('date', Carbon::today())->get()
}
我认为这将有助于仅从datetime字段获取日期。您可以使用whereDate
UserContent::where('status',1 )->whereDate('date', today())->get();
将日期字段添加到模型中的$dates道具中
protected $dates = ['date'];
protected $dates = ['date'];