adpozuelo
AHA! So after some testing within a sandbox environment:
<?php
// Set timezone to "Europe/Madrid"
$dbtz = new DateTimeZone('Europe/Madrid');
// Create timestamp from epoch timestamp: "Wednesday, July 30, 2025 1:48:30 PM UTC"
$D = DateTime::createFromFormat('U', 1753883310);
// Show the offset
var_dump($dbtz->getOffset($D));
The above outputs the 7200
offset like in your case. So your db2gmtime()
does appear to be borked in some capacity. So, $dbtime
should be the raw timestamp from the db like 2025-07-30 01:48:30
. Then $D
should be the same time but in epoch format (seconds since Unix Epoch). Then $dbtz
should be UTC
. So when it does $dbtz->getOffset($D)
that should return 0
but instead returns 7200
. This means the Europe/Madrid timezone is still being used on the db side somehow as shown in the example above.
When looking at the code the values are cached to prevent many db queries, etc. So maybe when you made the db change you never restarted the webserver and PHP-FPM. This would clear any server-side cache which should clear any cached variables like this. So I would recommend restarting the server, restarting PHP-FPM, checking your database timezones to ensure they were persisted, and retest.
Cheers.