Set default Timezone via htaccess in cPanel

Set default Timezone via htaccess in cPanel

Here in how to change the default Time Zone permanently in cPanel using the .htaccess file

Step 1. First, check you current time yone settings using a simple .php script like this:

<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "The time is " . date("h:i:sa");
?>

save it as timezone.php on your server and open the file in your browser, the output will be:

current timezone in php
current timezone in php

Step 2. Then, to change it, find your timezone format from this list of supported timezones by PHP

PHP timezones of Europe
PHP timezones of Europe

Step 3. In cPanel find and edit your .htaccess file and put the following code, but make sure to replace Europe/Belgrade with your timezone.

cpanel htaccess file
cpanel htaccess file
<IfModule php5_module>
 php_value date.timezone ="Europe/Belgrade"
</IfModule>

Step 4. Save it and go back to the script in step 1. to check if the timezone was updated.

timezone check php
timezone check php

For more .htaccess snippets make sure to check out my .htaccess Cheatsheet

PS. For php.ini simply use the following:

date.timezone ="Europe/Belgrade"
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.