Knowledgebase:
How can I change the timezone using PHP/.htaccess?
Posted by Brian F., Last modified by Brian F. on 29 March 2021 05:34 PM

In the event you need to localize your time via PHP for your applications/scripts/website, you can make the change easily via your .htaccess file. Please note the servers timezone cannot be changed however. For purposes of this article we'll be using cPanels File Manager, though these changes can be made via SSH or any FTP client (we suggest WinSCP). To change your timezone via .htaccess:

    1. Login to cPanel for your account, and in the top left finder search for File Manager.

    1. Select the File Manager icon, and you'll be greeted with a popup. On this dialogue, you'll want to select 'Web Root' for the directory also select 'Show Hidden Files (dotfiles)'.

    1. Once your File Manager opens, locate your .htaccess file and click it. Once highlighted, select 'Edit' from the top navigation. You will be prompted with another dialogue box, just hit 'Edit' to continue to the editor.

    1. Now that you're editing your .htaccess, add the following lines to your file:

      php_value date.timezone "America/Chicago"

      Replace "America/Chicago" with the timezone you wish to use. This will now change the timezone for your applications/sites to the one specified.

  1. If you need a list of all supported timezones, please reference the following URL: Supported PHP Timezones
(9 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).