Skip to content

[Docs] Improve function.date-default-timezone-get.php #4562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
camlafit opened this issue Mar 25, 2025 · 3 comments
Open

[Docs] Improve function.date-default-timezone-get.php #4562

camlafit opened this issue Mar 25, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@camlafit
Copy link

camlafit commented Mar 25, 2025

Affected page

https://www.php.net/manual/en/function.date-default-timezone-get.php

Current issue

When date.timezone is undefined date_default_timezone_get() return a different value regarding version used.

Suggested improvement

When date.timezone is undefined date_default_timezone_get() return :

  • UTC only if php version >= 8.2
  • current server timezone if php version <=8.1
@camlafit camlafit added the enhancement New feature or request label Mar 25, 2025
@philip
Copy link
Member

philip commented Mar 25, 2025

It appears this issue goes beyond date_default_timezone_get() although it's certainly a good start. It appears the change was not fully intentional or is complicated as per php/php-src#11496 -- in any case, this issue certainly deserves more digging into.

@camlafit
Copy link
Author

Hello

When I opened this issue I was not sure where to open it. I've yet identified this change and collateral effect.
When we try to check timezone effect on our server , we catch this inconsistance as :

  • before 8.2 ini_get("date.timezone") is empty and date_default_timezone_get() return timezone server
  • after 8.2 ini_get("date.timezone") is no more empty and return UTC , date_default_timezone_get() do same

To prevent developer to misunderstood this change, could be interesting to provide an "official" note as it's a breaking change.
An other effect we can't anymore detect if configuration is forced/configured to UTC or without any configuration. To detect this only solution looks to check all configuration file (php.ini, pool.d/*, ...)

Maybe could be set also at https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone

@FlyveHest
Copy link

This really should be noted, both on DateTime page, and in the upgrade appendices.

Just did a pretty big update fra 8.1 to 8.4, and now have a lot of work to fix all the incorrect timestamps in our backend, and we have gone through the appendices with utmost care to avoid situations exactly like this.

Not to mention the time it took to determine what had actually happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants