← ServerPilot Docs

How to Update the PHP timezonedb Version

This article is about updating the internal database of information PHP uses to determine the time based on any given timezone.

Need to change the actual timezone PHP is using? See our article on changing the PHP timezone.

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.

Updating the PHP timezonedb

The updated timezonedb can be installed as a PECL extension.

To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.
In the examples shown, replace "X.Y" with your app's PHP version (for example, "7.4").

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

Verifying the Installation

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.

Uninstalling the Updated timezonedb

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
Last updated: November 3, 2020

Launch your first site in 5 minutes