只是为了在上面的答案中添加更多内容,应该使用的实际方法是以下方法:
$date = new \Carbon\Carbon('-3 months'); // for the last quarter requirement
$date->startOfQuarter(); // the actual start of quarter method
$date->endOfQuarter(); // the actual end of quarter method (with time 23:59:59.999999)
以下不完全正确:
$date->firstOfQuarter(); /* use this method when you wish to get the first
occurrence of a given day in the current quarter, its
fallback works similar to the startOfQuarter() method */
$date->lastOfQuarter(); /* this is where the problem located, unlike the
endOfQuarter() method, this method return the start of a
day (with time 00:00:00.000000) (because the method is
designed to get the last occurrence of a given day in the
current quarter */