Carbon::now() - only month
Solution 1:
$now = Carbon::now();
echo $now->year;
echo $now->month;
echo $now->weekOfYear;
Update:
even this works since Laravel 5.5^
echo now()->month
Solution 2:
I think you've already worked this out in a comment, but just for clarity: Carbon extends PHP's native DateTime
class, so you can use any of the methods available on that, like format
:
Carbon::now()->format('M');
(where M
is the modifier for A short textual representation of a month, three letters)
Solution 3:
You can use these both ways to get the current month
Carbon::now()->month;
or
Carbon::now()->format('m');