Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel使用Carbon::today如何从datetime字段获取日期值?_Php_Laravel_Date_Datetime - Fatal编程技术网

Php Laravel使用Carbon::today如何从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

这是我的控制器代码。如何从datetime字段中获取日期值

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'];