If I understand correctly, you could get "now" Carbon::now(), subtract a month (or six) ->subMonths(6) and then get the start of the month ->startOfMonth().
So Carbon::now()->subMonths(6)->startOfMonth().
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I wish to fetch all the first day dates starting from last six months. How to do this in laravel?
I know that I can do this as like this :-
$firstDay = new \Carbon\Carbon('first day of January 2018'); $firstDay = new \Carbon\Carbon('first day of Febuary 2018'); $firstDay = new \Carbon\Carbon('first day of March 2018'); $firstDay = new \Carbon\Carbon('first day of April 2018');
and so on.. but I need to write in everytime for each month. I want to make it dynamic so that for every new month I can get the date.
If I understand correctly, you could get "now" Carbon::now(), subtract a month (or six) ->subMonths(6) and then get the start of the month ->startOfMonth().
So Carbon::now()->subMonths(6)->startOfMonth().
Please or to participate in this conversation.