Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save catwhocode/faa890f6284f967a14853f9fedda4912 to your computer and use it in GitHub Desktop.
Save catwhocode/faa890f6284f967a14853f9fedda4912 to your computer and use it in GitHub Desktop.
Laravel Timezone

Note

  • If your users come from many timezones, consider keep using UTC, leave the timezone configuration on the user side. Use this package for timezone conversion.
  • If you're using Laravel 11, you can use .env instead.

Open File App\Providers\AppServiceProvider

Change method boot

use Carbon\Carbon;


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

Open file config/app.php

Change separated values

'timezone' => 'Asia/Jakarta',

'locale' => 'id',

'faker_locale' => 'id_ID',

Display the date with Indonesian language

Try this step in views or controller also step is recommended here


Carbon\Carbon::parse('2019-03-01')->translatedFormat('d F Y');

Run this artisan commmand after setting the configuration

php artisan config:clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment