如何从 laravel 5.1 中数据库表的created_at属性中选择年份和月份?
2022-08-30 17:57:04
我的问题是,我想从属性中获取数据,仅按年和月。我尝试过的代码是:created_at
$post= Mjblog::select(DB::raw('YEAR(created_at) year, MONTH(created_at) month'));
$posts_by_y_m = $post->where('created_at',$post)->get();