During the development or lifecycle of your online project, you may need to adjust the time zone of web applications to ensure that dates and times are handled correctly. In this guide, we show how to change the time zone of a database from phpMyAdmin.
The default time zone for databases of a hosting created in cdmon is CEST or CET.
- CET (Central European Time): From the end of October until the end of March.
- CEST (Central European Summer Time): From the end of March until the end of October.
To modify the time zone of a database, it is essential to first access phpMyAdmin from your hosting management: How to access phpMyAdmin
There may be multiple databases in your hosting account. It is crucial to identify and select the database associated with the specific website or project you want to adjust.
Once inside phpMyAdmin and after selecting the appropriate database, you must go to the “SQL” tab where you can execute SQL commands directly.
Check the current time zone
To know which time zone is currently configured, run the following command:
SELECT @@GLOBAL.time_zone,
@@SESSION.time_zone;
If no changes have been made previously, the result of this command will be “SYSTEM”, which means that the time zone configured on the server is being used, as explained at the beginning of this guide. This command is useful to confirm the time zone before making any changes.
To adjust the time zone to a new one, use the command:
set time_zone='<TimezoneName>';
Replace <TimezoneName> with the desired time zone according to the IANA time zone format. In this link you can check the list of available TZ identifiers. For example, to change the time zone to U.S. Eastern Standard Time, you would use:
SET time_zone = 'America/New_York';
After entering the command, click "Continue" and phpMyAdmin should confirm that the change has been successfully applied.
After modifying the time zone settings, it is crucial to perform tests to ensure that everything works as expected, especially in applications sensitive to time changes such as calendar plugins or event management.
Reset to the system time zone
If you need to revert the changes and use the server’s time zone again, simply run:
SET time_zone = 'SYSTEM';