When countries change their timezones or daylight savings rules, such as which day they set clocks forward or backward, this can result in previous PHP versions not using the correct time for those recently changed timezones.
This problem can sometimes be resolved by switching your app to a newer PHP version.
If using a newer PHP version does not resolve the issue or you're unable to change the app's PHP version due to your app's code requiring an older PHP version, you can instead update the database PHP uses for timezone information.
The updated timezonedb can be installed as a PECL extension.
To install the updated PHP timezonedb, SSH in to your server as root and run the following commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo peclX.Y-sp install timezonedb
Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:
sudo bash -c "echo extension=timezonedb.so > /etc/phpX.Y-sp/conf.d/timezonedb.ini" sudo service phpX.Y-fpm-sp restart
You can verify PHP is using the updated timezonedb by running the command:
phpX.Y-sp -i | grep "Timezone Database"
You should see the following output:
"Olson" Timezone Database Version => 2020.4 Timezone Database => external Alternative Timezone Database => enabled Timezone Database Version => 2020.4
If you instead see "Timezone Database => internal" such as in this output:
"Olson" Timezone Database Version => 2020.1 Timezone Database => internal
then the updated timezonedb is not being used.
To uninstall this extension, as root run the commands:
sudo rm /etc/phpX.Y-sp/conf.d/timezonedb.ini sudo peclX.Y-sp uninstall timezonedb
Next, restart PHP-FPM with the command:
sudo service phpX.Y-fpm-sp restart