I want to get the year-related months list into the array. for an example:
$months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July ', 'August', 'September', 'October', 'November', 'December', );
I want to get the year-related months list into the array. for an example:
$months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July ', 'August', 'September', 'October', 'November', 'December', );
You can use Carbon package to get the result
public function getMonthListFromDate(Carbon $start, Carbon $to): array
{
$months = [];
foreach (CarbonPeriod::create($start, '1 month', $to) as $month) {
$months[] = $month->format('F');
}
return $months;
}