Laravel Carbon subtract days from current date

后端 未结 3 1678
抹茶落季
抹茶落季 2021-02-01 11:43

I am trying to extract objects from Model \"Users\" whose created_at date has been more than 30 days from today.

Carbon::now() ==> I want a

3条回答
  •  时光取名叫无心
    2021-02-01 12:26

    You can always use strtotime to minus the number of days from the current date:

    $users = Users::where('status_id', 'active')
               ->where( 'created_at', '>', date('Y-m-d', strtotime("-30 days"))
               ->get();
    

提交回复
热议问题