diff --git a/app/Helpers/Time.php b/app/Helpers/Time.php new file mode 100644 index 00000000..248ff55f --- /dev/null +++ b/app/Helpers/Time.php @@ -0,0 +1,25 @@ +getTimezone()->getOffset(CarbonImmutable::now('UTC')) / 3600); + + return sprintf('%s%s:00', $offset > 0 ? '+' : '-', str_pad(abs($offset), 2, '0', STR_PAD_LEFT)); + } +} diff --git a/config/database.php b/config/database.php index 32fca758..5a4e8bc7 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,7 @@ 'utf8mb4_unicode_ci', 'prefix' => env('DB_PREFIX', ''), 'strict' => env('DB_STRICT_MODE', false), + 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE'))) ], /* @@ -65,6 +68,7 @@ return [ 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => false, + 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE'))) ], ],