Support the ongoing development of Laravel.io →
Input Architecture Testing
Last updated 2 years ago.
0

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);
Last updated 2 years ago.
0
<?php dd( DateTime::createFromFormat('m', '11')->format('F') ); // Output: string(8) "December" ?>

Even the simplest of setup causes this function to fail on "m" or "n"...

Last updated 2 years ago.
0
	$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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.