【问题标题】:Laravel get entry from mySql database where timestamp is not older than one dayLaravel 从 mySql 数据库中获取时间戳不超过一天的条目
【发布时间】:2019-12-10 21:14:07
【问题描述】:

在 laravel 项目中,我有 mysql 表“用户”,其中是名为 last_visit 的时间戳列。我想获取所有 last_visit 不超过一天的用户。如何执行?

【问题讨论】:

    标签: mysql laravel get timestamp where-clause


    【解决方案1】:

    你可以结合where clausesCarbon来归档你​​想要的:

    DB::table('users')->where('last_visit', '>', Carbon::today()->subDay(1));
    

    Usee::where('last_visit', '>', Carbon::today()->subDay(1));
    

    【讨论】:

      【解决方案2】:

      你可以试试: $user_last_visit = User::whereRaw('last_visit > (NOW()-INTERVAL 1 DAY)');

      希望对您有所帮助

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-03
        • 2020-10-21
        • 2021-05-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多