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:
You can see all the supported time zones here: http://php.net/manual/en/timezones.php
date.timezone = ‘Region/Zone’
eg: date.timezone = ‘Europe/London’
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.