How can I use Carbon to determine the current quarter? I.e. I would like to get hold of the date when the quarter started and the date when it ends.
I tried the intuitive echo new Carbon('this quarter');
way which doesn't work, but I guess they don't have one for quarters.
I figured it out, I did:
$query->where(DB::raw('QUARTER(FT.created_at)'), Carbon::now()->quarter);
$query->where(DB::raw('YEAR(FT.created_at)'), '=', Carbon::now()->year);
But now I am struggling with how to get the start and end date of the last quarter.
QUARTER(FT.created_at)
, So you might don't need to be worry about the start or end date of the quarter anymore. Why don't you just pass 4 into the query? – Accelerometer