我希望在Laravel 5.1中获取上一周插入的数据。目前我正在使用以下查询:
$AgoDate=\Carbon\Carbon::now()->subWeek()->format('Y-m-d'); // returns 2016-02-03
$NowDate=\Carbon\Carbon::now()->format('Y-m-d'); // returns 2016-02-10
$query->whereBetween('created_on', array($AgoDate,$NowDate));
这会返回最近7天的数据,但我需要上周的数据,也就是从1月31日到2月6日的数据,即上一周的数据。
注意:在我的情况下,一周从星期天开始,到星期六结束。
http://stackoverflow.com/questions/28936174/how-can-i-get-last-week-current-week-and-last-month-record-from-mysql/28936788#28936788
,如果不是你想要的,请告诉我。 - Mobasher Fasihy