Add the ability to use ->local on dates to use local timezone
This commit is contained in:
parent
b1b46190fc
commit
a44f3e77df
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
|
@ -24,6 +25,10 @@ class AppServiceProvider extends ServiceProvider
|
|||
public function boot(): void
|
||||
{
|
||||
$this->configureDefaults();
|
||||
|
||||
Carbon::macro('local', function () {
|
||||
return $this->tz(config('app.display_timezone', 'UTC'));
|
||||
});
|
||||
}
|
||||
|
||||
protected function configureDefaults(): void
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ return [
|
|||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'display_timezone' => env('APP_DISPLAY_TIMEZONE', 'UTC'),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue