Changing default time zone using WHM / cPanel

iSumitG

Member
Apr 15, 2012
11
0
51
cPanel Access Level
Root Administrator
I have changed time zone of my server to "Asia/Kolkata" in WHM by going to the path:
Home > Server Configuration > Server Time

But still my website is showing timezone as "America/Denver" when I check it using PHP.

I have pasted the following code in test.php file in public_html directory of my domain.

PHP:
echo 'Time zone is: '.date('e');
echo 'Time zone is: '.date_default_timezone_get();
I have 3 websites on my server, all of them having the same problem. What should be done to get the time zone same as WHM in all websites?

Two solutions can be to set a default timezone using PHP or .htaccess. But I want to know why default timezone is not showing as Asia/Kolkata even if server timezone is set to Asia/Kolkata in WHM.
 
Last edited:

JaredR.

Well-Known Member
Feb 25, 2010
1,834
25
143
Houston, TX
cPanel Access Level
Root Administrator
You can change PHP's time zone by clicking Home » Service Configuration » PHP Configuration Editor, and clicking the Advanced Mode radio button. The setting to change is date.timezone. This applies to all sites on the server unless overridden by custom php.ini files.