Laravel $q->where() between dates

前端 未结 4 1059
死守一世寂寞
死守一世寂寞 2020-11-30 02:49

I am trying to get my cron to only get Projects that are due to recur/renew in the next 7 days to send out reminder emails. I\'ve just found out my logic doesn\

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 03:31

    Didn't wan to mess with carbon. So here's my solution

    $start = new \DateTime('now');
    $start->modify('first day of this month');
    $end = new \DateTime('now');
    $end->modify('last day of this month');
    
    $new_releases = Game::whereBetween('release', array($start, $end))->get();
    

提交回复
热议问题