Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel carbon get current month in dutch

I'm trying to show the full current month name in dutch. I've tried it like this:

\Carbon\Carbon::now()->subMonth()->format('F')

But then I see July so not what I want. My app service provider looks like this:

public function boot()
{
    Carbon::setLocale('nl');
}

Any Idea what I could do to get this to work?

(diffForHumans is working correctly)

like image 298
Jamie Avatar asked Jul 17 '17 07:07

Jamie


People also ask

How do you find the current month in Carbon?

$now = Carbon\Carbon::now(); $month = $now->format('m'); Assuming the current month was January, you would receive '01' from that format call. As an aside, if that's all you're using Carbon for in that class, you could just use the default PHP date() method if you feel like using less dependencies.


1 Answers

If you don't want to pull an entire package and want to only install your locale, then you could list the locale installed in your (linux) server by issuing the command

locale -a

If your locale isn't listed, then you may install your locale nl using the command

sudo locale-gen nl
sudo update-locale

then the usual setLocale

like image 101
linktoahref Avatar answered Sep 23 '22 18:09

linktoahref