我有一个类似这样的数据2014-12-30 09:07:49
分配给 created_at。
我有一个数字,12 作为参数值。我想做的是,我想将数字 12 与上面的 created_at 进行比较,并以月份为目标。我该怎么做。
我发现,Laravel 在检索数据期间会自动将这些 created_at 转换为 Carbon Object。有没有办法在检索期间提取 created_at 的月份部分?
public function filterUser($month){
$user = User::where('created_at', $month)->get();
}
显然,上面的代码不起作用。我发现这样做CarbonObject->month
会从时间戳/碳对象中获取月份。但是我将如何为我的问题实施这个想法。