Add the ability to use ->local on dates to use local timezone

This commit is contained in:
Matt Young 2026-01-28 02:50:12 -06:00
parent b1b46190fc
commit a44f3e77df
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -66,6 +66,8 @@ return [
*/
'timezone' => 'UTC',
'display_timezone' => env('APP_DISPLAY_TIMEZONE', 'UTC'),
/*
|--------------------------------------------------------------------------