Changing the server timezone in PHP scripts

By default, PHP scripts use the timezone of the server, which is set according to the location of the datacenter. See Server Timezone.

To change the timezone setting for your PHP scripts, you need to adjust the date.timezone value in a php.ini file. The global php.ini file for your account can be created/edited through the PHP settings section of the hosting Control Panel. You can read more about working with php.ini files in this section of our online manual.

The following line in your php.ini file has to be added or edited:

date.timezone = "UTC"

You should replace UTC with the timezone that is appropriate for your location. The list of valid timezones in the current version of PHP is available at http://php.net/timezones.

NOTE for PHP 5.3 user: If your account uses PHP 5.3 as a default PHP interpreter, besides changing the date.timezone setting in your php.ini file, you need to add the following line to a .htaccess file:

SetEnv TZ

The .htaccess file should be located in the folder that contains your PHP scripts, or in an upper level folder - .htaccess files work recursively.

NOTE about MySQL: 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 to this section of our online manual for instructions on doing so.