How To Change Default Time Zone Via htaccess File in cPanel

Hi,

Do you want to change the default time zone of your cPanel account? Well, this can easily be done by adding some commands in a PHP script. But, before doing that, you should have an idea that how the default time zone works, how it can be beneficial to change the default timezone of your cPanel, and why one should change the default time zone of their cPanel accounts.


Why One Should Change The Default cPanel Time Zone?

If you’ve ever run a cron job from your cPanel, you might have faced some issues. This might be because the cPanel Timezone may be different from the Server’s timezone. Not only that, if your server timezone is different from the cPanel timezone, you will surely face some other crucial issues which must be solved immediately.

How to change default timezone via htaccess in cPanel

Matching the cPanel timezone with the server timezone will reduce the possibility of getting errors while adding any new Cron Job or performing other tasks inside the cPanel.

In conclusion, it is recommended to always match your cPanel timezone with the server timezone to avoid any extra internal errors.

How to change the default Time Zone permanently via the .htaccess file? [Important| Updated 2022]

First of all, you can watch our step-by-step video guide to change the default timezone of your cPanel account via htaccess if you’re not in the mood to read articles.

We were checking the comments section of our blog where we found a request to create a step-by-step tutorial to change the default timezone of cPanel, and here we are. You can follow the below steps or watch the above video to change the default cPanel timezone via the htaccess file.


Change The Default Timezone Easily

  • Login to your cPanel. You can use Example.com/cpanel or Example.com:2083 URL to log into your website. (Change example.com with your custom domain name).

Log into cPanel

  • Now click over the File Manager and then go inside your root directory (public_html).

Root directory public-html

  • Create a new file with any (test.php) name.

Create a new file in cpanel

  • Now open the newly created file by clicking over the Edit button, and paste the below command.
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "The time is " . date("h:i:sa");
?>
How to Change Default Timezone in .htaccess| best linux hosting provider
How to Change Default Timezone in .htaccess
  • Hit the Save Changes button and close the file.
  • Now open the .htaccess file present inside your public_html and open it by clicking over the Edit button.
How to Change Default Timezone in .htaccess| cheapest linux hosting provider
How to Change Default Timezone in .htaccess
  • Paste the below command in the .htaccess file & hit the Save Changes button.

<IfModule php5_module>
php_value date.timezone =”Asia/Kolkata”
</IfModule>


It’s done!!!!

  • Now hit the file from outside by entering example.com/test.php in the URL. (Replace the example.com with your domain name).
How to Change Default Timezone in .htaccess| cheapest linux hosting provider
How to Change Default Timezone in .htaccess

You’ve successfully changed your cPanel default timezone. Moreover, you can do it from the MultiPHP INI Editor also that is present inside your cPanel itself. Let me show you how:

Change The Default Timezone – Method 2

  • Simply log in to Cpanel and go inside MultiPHP INI editor.
  • Click on Editor Mode.
  • Select your primary domain and edit a simple code given below and save it.
date.timezone="Asia/Kolkata"
How to Change Default Timezone in .htaccess| cheapest linux hosting provider
How to Change Default Timezone in .htaccess.

This method is also working fine till now (March 2022). However, it is up to you which method you choose to change the default timezone of your cPanel account. Both will do the same.

Hope this helps you!!!!

Thanks for Reading!!!!