Search code examples
phplaraveldatelocaledate-format

change date format to local language


I want to change date format in english language("Monday, 04 July 2020") to indonesia(Senin, 04 Juli 2020). I change config/App.php

'locale' => 'id',

and add some code to Providers/AppServiceProvider.php

   public function boot()
    {
        config(['app.locale' => 'id']);
        Carbon::setLocale('id');
        date_default_timezone_set('Asia/Jakarta');
    }

my model

 public function dateFormat()
    {
        return \Carbon\Carbon::parse($this->attributes['tanggal_acara'])
        ->formatLocalized("%A, %d %B %Y");
    }

and this my blade

{{ $event->dateFormat() }}

but the result still same "Monday, 04 July 2020"

anyone tell me what I've missed?


Solution

  • solved use this liblary https://github.com/jenssegers/date

    This date library extends Carbon with multi-language support. Methods such as format, diffForHumans, parse, createFromFormat and the new timespan, will now be translated based on your locale.