![](/img/trans.png)
[英]how can i make this dynamic BETWEEN '2014-07-01 00:00:00' AND '2014-07-31 23:59:59'";
[英]How to type within today From 00:00:00 to 23:59:59 in Laravel
如何在Laravel中添加“今天內”(即從00:00:00到23:59:59)?
$grpcnt = DB::table('groups')
->where('owner_id', $u_id)
->whereBetween('created_at', xxx,xxx)
->count();
如果您想獲得今天組的數量,則可以這樣使用。
DB::table('groups')->where('owner_id', $u_id)
->whereDate('created_at', Carbon::today())
->count();
或根據您的要求
$start = Carbon::now()->startOfDay(); //2019-07-27 00:00:00.000000
$end = Carbon::now()->endOfDay(); //2019-07-27 23:59:59.000000
DB::table('groups')->where('owner_id', $u_id)
->whereBetween('created_at', [$start, $end])->count();
您可以在一天的開始和結束時使用碳
$grpcnt = DB::table('groups')
->where('owner_id', $u_id)
->whereBetween('created_at', [ Carbon::now()->startOfDay(),Carbon::now()->endOfDay()])
->count();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.