I looked up the Carbon method createFromFormat, which appears to just be a wrapper for DateTime::createFromFormat. I read about a bug that is caused by not supplying a year/day to cFF. I updated the code, same result.
$dates = [];
$month = '';
for ($i=1; $i <= 12; $i++) {
$month = DateTime::createFromFormat('Y-n-d', date('Y')."-$i-".date('d'))->format('F');
$dates[$i] = $month;
}
return dd($dates);
Even the simplest of setup causes this function to fail on "m" or "n"...
$dates = [];
for ($i=1; $i <= 12; $i++) {
$dates[] = Carbon::createFromFormat('Y-n-d', "$year-$i-01")->format('F');
}
return dd($dates);
Seems to work, I knew that there was a bug with the days rolling over but I overlooked that in the last post. I suggest looking through your code if anyone else uses a month conversion without a day.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community