If you pass day = 1 then you can get today's post by whereDate laravel function.
e.g. pass day = 1
$today = date('Y-m-d');
$post = DB::table('post')->whereDate('post_date', $today)->get();
If you pass day = 2 then first of all you have to get previous date and get current date by date function and using whereBetween laravel function you can get yesterday and today's post.
e.g. pass day = 2
$from = Yesterday date
$to = today date
$post = POST::whereBetween('post_date', [$from, $to])->get();
1条答案
按热度按时间bpsygsoo1#