By default, PHP scripts use the timezone of the server, which is set according to the location of the data center. For more details, check our Server Timezone article.
To change the timezone setting for your PHP scripts, you need to adjust the value of the date.timezone PHP directive. To do this for a domain/subdomain, you should access the hosting Control Panel -> PHP settings section and follow these steps:
- Click on the Manage button next to the domain/subdomain.
- Select your preferred timezone from drop-down menu next to the date.timezone directive under the Directives section. If you cannot see the date.timezone directive, click on the Show additional directives button and all the PHP directives manageable through the interface will be displayed.
- Click on the Save changes button.
You can also change the date.timezone value by manually adding the following line to a PHP configuration file:
date.timezone = "custom_timezone"
Make sure that you replace custom_timezone with the timezone that is appropriate for your location. The list of valid time zones in the current version of PHP is available at https://php.net/timezones.
More details on how to change the PHP settings in your account are available in our Changing PHP settings article.
Changing the timezone for PHP 5.3
PHP 5.3 is obsolete, and we encourage all customers to stop using it.
If you wish to change the timezone for scripts running on PHP 5.3, besides changing the date.timezone setting in your PHP configuration file, you need to add the following line to an .htaccess file:
The .htaccess file should be located in the folder that contains your PHP scripts or in an upper level folder as .htaccess files work recursively.
Changing the timezone for MySQL sessions
Changing the timezone for PHP scripts does not apply to the MySQL server. If you use the internal MySQL date functions, they will return the system time, so any date conversions should be done in your scripts. Please refer our Setting MySQL session time zone article for instructions on doing so.