Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Laravel 应用程序中,我有像 01、02、03 到 12 这样的月份编号。我想得到这个月的所有天数。我不能使用daysInMonth()因为我没有日期,我只有月数。
Carbon::now()->daysInMonth();
我怎么能做这个?
你可以这样做
Carbon::now()->month($month_number)->daysInMonth; // ... Carbon::now()->month(02)->daysInMonth; // 28
你也可以这样做
Carbon::createFromDate(null, $number_of_month, 1)->daysInMonth;