Php 如何使用laravel 5.3中查询生成器中的时间戳来标记过去5天内注册的用户

Php 如何使用laravel 5.3中查询生成器中的时间戳来标记过去5天内注册的用户,php,mysql,laravel-5.3,Php,Mysql,Laravel 5.3,我想列出最近5天注册的用户。。要列出所有用户,请使用以下查询 $users = User::select('*')->orderby('created_at', 'desc')->get(); 像这样把它带到视野中 <table class="table table-hover"> <tbody><tr> <th>I

我想列出最近5天注册的用户。。要列出所有用户,请使用以下查询

$users = User::select('*')->orderby('created_at', 'desc')->get();
像这样把它带到视野中

<table class="table table-hover">
                            <tbody><tr>
                                <th>ID</th>
                                <th>User Name</th>
                                <th>Email</th>
                                <th>Country</th>
                                <th>Date</th>
                                <th>Points</th>
                            </tr>

                            <?php foreach ( $users as $u ){ ?>

                            <tr>
                                <td>{{ $u->id }}</td>
                                <td>{{ $u->user_name }}</td>
                                <td>{{ $u->email }}</td>
                                <td>{{ $u->country }}</td>
                                <td>{{ $u->created_at }}</td>
                                <td>{{ \App\Points::getUserPoints($u->id) }}</td>
                            </tr>



                            <?php }?>

                            </tbody></table>

身份证件
用户名
电子邮件
国家
日期
要点
{{$u->id}
{{$u->user_name}
{{$u->email}
{{$u->country}
{{$u->created_at}
{{\App\Points::getUserPoints($u->id)}
但是,为了获取在过去5天内注册的用户,查询将是什么。。??任何人请告诉我一个好的查询。

您可以使用()来执行此操作:

    $now = Carbon::now();
    $users = User::where('created_at', '>=', $now->subDays(5))->get();
确保在文件顶部“
使用Carbon\Carbon;