Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Get Days In Month From Month Number?

In Laravel Application I have month number like 01, 02, 03 upto 12. I want to get all days in this month. I cannot use daysInMonth() as I do not have a date all I have is month number.

Carbon::now()->daysInMonth();

how can I make this?

like image 854
Saad Ramay Avatar asked Jan 24 '26 07:01

Saad Ramay


1 Answers

You can do so

Carbon::now()->month($month_number)->daysInMonth;

// ...

Carbon::now()->month(02)->daysInMonth; // 28
like image 145
mmabdelgawad Avatar answered Jan 25 '26 21:01

mmabdelgawad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!