Skip to content

fix: respect TZ env var as fallback for timezone config#2753

Merged
alexjustesen merged 2 commits into
alexjustesen:mainfrom
ItsAbdiOk:fix/respect-tz-env-var
Apr 19, 2026
Merged

fix: respect TZ env var as fallback for timezone config#2753
alexjustesen merged 2 commits into
alexjustesen:mainfrom
ItsAbdiOk:fix/respect-tz-env-var

Conversation

@ItsAbdiOk
Copy link
Copy Markdown

Summary

Add TZ as a fallback in the env chain for both timezone and display_timezone in config/app.php, so the standard Docker TZ variable is respected when APP_TIMEZONE / DISPLAY_TIMEZONE are not set.

The problem

Docker users typically set timezone via TZ=Europe/London in their compose file. Currently, both config values fall back directly to 'UTC', ignoring TZ entirely. This causes times to display in UTC even when the container's system clock is correct.

This has been reported in #939, #1503, #805, #1739, and #1214 — all closed with "set APP_TIMEZONE and DISPLAY_TIMEZONE" as the workaround.

The fix

// Before
'timezone' => env('APP_TIMEZONE', 'UTC'),
'display_timezone' => env('DISPLAY_TIMEZONE', 'UTC'),

// After
'timezone' => env('APP_TIMEZONE', env('TZ', 'UTC')),
'display_timezone' => env('DISPLAY_TIMEZONE', env('TZ', 'UTC')),

Resolution order: APP_TIMEZONETZUTC

Non-breaking — existing deployments with APP_TIMEZONE or DISPLAY_TIMEZONE are unaffected.

Add TZ as a fallback in the env chain for both timezone and
display_timezone so that the standard Docker TZ variable is
respected when APP_TIMEZONE / DISPLAY_TIMEZONE are not set.
@ItsAbdiOk ItsAbdiOk requested a review from alexjustesen as a code owner April 13, 2026 05:37
Comment thread config/app.php
Addresses review feedback from @alexjustesen — easier to read.
@alexjustesen alexjustesen merged commit 82831ab into alexjustesen:main Apr 19, 2026
@ItsAbdiOk ItsAbdiOk deleted the fix/respect-tz-env-var branch April 19, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants