Level 122
there is a daysInMonth attribute?
Carbon\Carbon::now()->daysInMonth
https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php#L44
9 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I don't know how I can't find this anywhere on the web.
public static function months($futureM) {
$now = Carbon::now();
$start = (new DateTime($now->format('Y-m-d')))->modify('first day of this month');
$end = (new DateTime(($now->addMonths($futureM))->format('Y-m-d')))->modify('first day of next month');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
$months = array();
foreach ($period as $dt) {
array_push($months, array('month'=>$dt->format("F/Y"), 'days'=> ));
}
return $months;
}
I need to get number of certain month days. How can I do that?
Please or to participate in this conversation.