In this post we explain how to set the PHP time zone.
You don’t have access to change the server time as it would require root/administrator privilege and we can’t provide you that on a shared hosting service for security reasons.
However, you can change PHP time zone for your account by editing the .htaccess file.
Because we use CloudLinux in our servers a local php,ini file won’t work but instead PHP values in .htaccess will work. So if you own a shared hosting account with us, here is what you need to do to change the PHP time zone.
- Login to your account via SSH or cPanel
- Open the .htaccess file in public_html directory with a text editor or open the file via cPanel >> File Manager (Since .htaccess is a hidden file, check the box for “Show Hidden Files (dotfiles)” in the pop-widow).
- Add the following line in the beginning or end of the file.
php_value date.timezone ‘Region/Zone’
eg: php_value date.timezone = ‘Europe/London’
- Save the changes and exit.
Here are some of the default time zones:
America/Chicago
America/Buenos_Aires
America/Detroit
America/Mexico_City
America/Sao_Paulo
America/Toronto
America/Vancouver
Europe/Amsterdam
Europe/Athens
Europe/Berlin
Europe/Brussels
Europe/Copenhagen
Europe/Istanbul
Europe/Lisbon
Europe/London
You can see all the supported time zones here: http://php.net/manual/en/timezones.php
If you are a VPS or dedicated server customer, you need to create a php.ini file instead of .htaccess file and add the following directive.
date.timezone = ‘Region/Zone’
eg: date.timezone = ‘Europe/London’
Useful Resources:
We hope you found this article on how to change the PHP time zone useful.
If you have any suggestions or questions please comment below.
I think .htaccess value should be in the format below.
php_value date.timezone “America/Los_Angeles”