Skip to content

fix(php): respect project timezone, fixes #69 - #73

Merged
stasadev merged 1 commit into
mainfrom
20261008_stasadev_timezone
Oct 8, 2026
Merged

stasadev merged 1 commit into
mainfrom
20261008_stasadev_timezone

Conversation

@stasadev

@stasadev stasadev commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

PHP in FrankenPHP always used UTC and ignored the project timezone. DDEV's start.sh now updates /etc/php-zts/php.ini too.

The Issue

On startup, DDEV's start.sh sets date.timezone from TZ, but only in $(find /etc/php -name php.ini). The add-on copies php.ini to /etc/php-zts/php.ini at build time, so the php-zts config kept date.timezone = UTC:

$ ddev php -r 'var_dump(date_default_timezone_get());'
string(3) "UTC"

The tests didn't catch it, because the test .ddev/php/php.ini overrode date.timezone itself.

How This PR Solves The Issue

Patches start.sh to also search /etc/php-zts:

find /etc/php /etc/php-zts -name php.ini

This line is the same in every DDEV version from v1.24.10 (the minimum supported) to HEAD.

Manual Testing Instructions

ddev add-on get ddev/ddev-frankenphp --pr 73
# Optional, set a specific timezone:
ddev config --timezone=Europe/London
# Or unset it to use your host timezone:
ddev config --timezone=""
ddev restart
ddev php -r 'var_dump(date_default_timezone_get());'

It should print the configured timezone, for example string(13) "Europe/London", or your host timezone if timezone is unset.

Automated Testing Overview

  • setup() runs ddev config --timezone=Europe/London, and health_checks checks date_default_timezone_get() in PHP.
  • The test .ddev/php/php.ini (from Custom PHP configuration does not take effect in FrankenPHP #41) now sets the unimportant highlight.comment = #123456 instead of date.timezone, so it no longer hides the project timezone. health_checks checks it with ini_get().

Release/Deployment Notes

Users need to run ddev add-on get ddev/ddev-frankenphp and ddev restart to get the fix.

🤖 Generated with Claude Code

## Short Summary (TL;DR)

PHP in FrankenPHP always used `UTC` and ignored the project timezone. DDEV's `start.sh` now updates `/etc/php-zts/php.ini` too.

## The Issue

- Fixes #69

On startup, DDEV's `start.sh` sets `date.timezone` from `TZ`, but only in `$(find /etc/php -name php.ini)`. The add-on copies `php.ini` to `/etc/php-zts/php.ini` at build time, so the php-zts config kept `date.timezone = UTC`:

```
$ ddev php -r 'var_dump(date_default_timezone_get());'
string(3) "UTC"
```

The tests didn't catch it, because the test `.ddev/php/php.ini` overrode `date.timezone` itself.

## How This PR Solves The Issue

Patches `start.sh` to also search `/etc/php-zts`:

```
find /etc/php /etc/php-zts -name php.ini
```

This line is the same in every DDEV version from v1.24.10 (the minimum supported) to HEAD.

## Manual Testing Instructions

```bash
ddev config --timezone=Europe/London
ddev add-on get ddev/ddev-frankenphp --pr REPLACE_ME_WITH_THIS_PR_NUMBER
ddev restart
ddev php -r 'var_dump(date_default_timezone_get());'
```

It should print `string(13) "Europe/London"`.

## Automated Testing Overview

- `setup()` runs `ddev config --timezone=Europe/London`, and `health_checks` checks `date_default_timezone_get()` in PHP.
- The test `.ddev/php/php.ini` (from #41) now sets the unimportant `highlight.comment = #123456` instead of `date.timezone`, so it no longer hides the project timezone. `health_checks` checks it with `ini_get()`.

## Release/Deployment Notes

Users need to run `ddev add-on get ddev/ddev-frankenphp` and `ddev restart` to get the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@stasadev
stasadev merged commit 1ffd93d into main Oct 8, 2026
12 checks passed
@stasadev
stasadev deleted the 20261008_stasadev_timezone branch October 8, 2026 10:59
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.

Timezone is not respected in PHP

1 participant