Change TimeZone of website cPanel htaccess

How To Change TimeZone of Website Through cPanel (.htaccess)?

Every server has a specific timezone, which is based on the presence of location of the servers. If the server is located in Spain, then the server will most likely to be set as the European TimeZone. If you would like to change the timezone of a website, then it can be easily done through the .htaccess file. .htaccess is a configuration file which is used on web servers running the Apache Web Server software. .htaccess files can be used to change the configuration of the Apache Web Server software to enable/disable additional functionality/features that the Apache Web Server software has to offer. We are going to use this for one such purpose, which is Changing TimeZone of a website through cPanel.

Steps for Changing the TimeZone in A Website .htaccess file

STEP 1: Login

Log in your cPanel account.

STEP 2: File Manager

Type ‘File Manager’ in the search box and click on it.

File Manager in cPanel

STEP 3: Settings

Click on ‘Settings’ in the right corner of the page.

Settings Option in cPanel

STEP 4: Show Hidden Files

Now, select the document root of your domain and be sure the checkbox next to ‘Show Hidden Files’ is checked. Click on ’Save Button’.

Show Hidden Files to edit htaccess in cPanel

STEP 5: .htaccess file

Look for the .htaccess file and right click on it. A small menu screen appears. Click on ‘Edit’.

Edit htaccess file to change timezone

STEP 6: Change the Timezone

In the .htaccess editor, paste the following code at the top of the page to configure your account. In this example, we are setting the timezone to IST(Indian Standard Time). Go through the Complete list of timezones supported by PHP

#Adjust default time zone

SetEnv TZ Asia/Kolkata

STEP 7: Save Changes

Finally, click on ‘Save Changes’ in the top right corner to save the .htaccess configuration.

If this doesn’t work for your website, then you can check below methods.

Bonus Methods

  • Instead of SetEnv TZ Asia/Kolkata give it as php_value date.timezone "Asia/Kolkata"
  • In PHP, placing this directly in your php.ini file:
    date.timezone = "Asia/Kolkata"
  • config file:
    date_default_timezone_set('Asia/Kolkata')

Therefore, by this article, you will come to know how to change the timezone of a website using cPanel.

[Tweet “How To Change TimeZone Of Website Through cPanel(.htaccess)?”]