Wednesday, March 1, 2017

Laravel best way of using setlocale with carbon

I am new to the laravel framework and OOP. I am building a small webapp.

One of the things what comes back every time on the website is the date of today. To generate the date of today I use Carbon like so

in my view.

That works fine and gives me back the following: "1 March 2017". Because my application is suppose to be in dutch i've searched for a function to set the dates to dutch. I've found this: setlocale(LC_ALL, 'nl_NL'); What works just fine except I have to add it to every controller method I use for the views where I need the date.

Is there a better/cleaner solution for this? Like somewhere I can set it global.




via Gijsberts

Advertisement