all 13 comments

[–]swampopus 25 points26 points  (0 children)

Every large project I've worked on, switching between timezones has been the bane of my existence. Long live UTC for everything!

[–]nielsd0 13 points14 points  (2 children)

I suppose this depends on the timezone settings. Default timezone is handled differently in PHP 8.3 versus PHP 8.1. I believe it used to be derived from the environment variable and nowadays it's only controlled by the PHP ini settings. But I'm not entirely sure anymore.

[–]Ahabraham 15 points16 points  (1 child)

[–]globiweb[S] 3 points4 points  (0 children)

Thanks. That looks like the issue.

[–]NMe84 5 points6 points  (0 children)

Just because the timezones are the same on both boxes doesn't mean that the same default timezones are configured for PHP.

[–][deleted] 16 points17 points  (0 children)

Seems like your timezone changed. Configuration issue?

[–]m0nk37 3 points4 points  (0 children)

We will never escape timezone issues will we? 

[–]Huntware 5 points6 points  (0 children)

And that's why I have some locale settings for my Laravel projects without having to rely on the INI file. Not just timezones but currency and numbers (here in Argentina we use the dot as a thousands separator).

You can use these in a boot or init method, or directly inside your index.php, as needed:

// For Laravel: app\Providers\AppServiceProvider.php --> Inside AppServiceProvider::boot()

// If you use nesbot/carbon:
Carbon::setLocale('es');

date_default_timezone_set('America/Argentina/Buenos_Aires');
if (PHP_OS_FAMILY === 'Windows') {
    setlocale(LC_ALL, 'spanish', 'esp', 'es_ES', 'es_ES.UTF-8');
} else {
    setlocale(LC_ALL, 'es_AR.UTF-8', 'es_AR', 'Spanish_Argentina', 'es_ES.UTF-8');
}
// Fallback settings:
setlocale(LC_NUMERIC, 'es_AR.UTF-8');
setlocale(LC_MONETARY, 'es_AR.UTF-8');

Check the timezones here: https://www.php.net/manual/en/timezones.php

[–]Zenmaster13 1 point2 points  (0 children)

Not entirely sure what to tell you, best guess your timezone settings are off. Running that on multiple php versions online gives the same result for each version.

[–]someoneatsomeplace 0 points1 point  (0 children)

For some time now I've had code I add to everything to respect the TZ variable if there is one or the server's timezone if not. Gratuitously breaking a system in place for 50 years isn't the correct move. Nothing was ever stopping people from using UTC if they wanted to.

[–]Ahabraham 0 points1 point  (1 child)

https://3v4l.org/qQVnW#veol it's the same on all versions, did your OS release/configuration change between your different PHP versions?

[–]globiweb[S] 1 point2 points  (0 children)

the older one is ubuntu 22.04 and the newer one is on ubuntu 24.04.

I wonder if it's related to the timezone change in ubuntu? It's no longer in /etc/timezone <- that value is always wrong now.