lewis4u lewis4u - 18 days ago 5
PHP Question

Carbon::now() - only month

I couldn't find anywhere in http://carbon.nesbot.com/docs/ how to show current year or month with Carbon?

when i write this:

Carbon\Carbon::now('m');


it gives me the whole time stamp, but I just need the month

like

date('m');


but it must be Carbon!

How can I achieve this?

Answer
$now = Carbon::now();
echo $now->year;
echo $now->month;
echo $now->weekOfYear;
Comments