I've set these variables the when I echo them out I get the following
2018-01-01
2018-01-31
2017-12-01
2017-12-31
2017-11-01
2017-12-01
As you can see the $last_day_of_month_2 doesn't work. I Assume it's because there are 31 days in this month and only 30 in November so Carbon::now()->endOfMonth()->modify('-2 months') can't find 31st - 2 months because there isn't one. Is there any easy way to get the first and last dat of the current month and then past 2 months?
@tykus Yeah that kind of works I justt needed to remove the ->toDateString()
otherwise got an error then needed to add a 2 in the $first_day_of_month_2subMonth()
Sorry, let me try that again; of course $first_day_of_the_current_month, $first_day_of_month_1 and $first_day_of_month_2 all are strings as a result of toDateString() (my bad!)
Also, in the last case I should have used subMonths(2) rather than subMonth().
Thanks for the update I pretty much figured it out after your first comment, that helped a lot. I've updated the bet answer to the correct one though :)