John Davidson

php - CarbonPeriod pass february

0 comments
Message:


$start_day = $installment->'2021-01-29';
$end = Carbon::createFromFormat('Y-m-d', $start_day)->addMonth(24);
$period = CarbonPeriod::create($start_day, '1month', $end);

$years = [];
foreach ($period as $date) {

$years[$date->format("Y")][$date->format("m")]['title'] = $date->format("d ") .$date->format("n"));

}

result


"29 January"
"01 March"

It pass february . I wanna it to be 28 february istead of 1 march . 29 january 28february and 29 march



My Answer:
1;
$end_day = $installment->copy()->endOfMonth()->day;

$period = CarbonPeriod::create("2022-02-$start_day", "2022-02-$end_day");

Rate this post

5 of 5 based on 4482 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us