Setting the PHP Timezone in the php.ini File

 If you get this error:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.


Then create/open the file named php.ini in the same folder as the file giving the error.

In the same folder create or open the file named .htaccess.

In .htaccess put this code:

<IfModule mod_suphp.c>
        suPHP_ConfigPath /home/cpanelusername/otherfoldersifany/php.ini
        <Files php.ini>
                order allow,deny
                deny from all
        </Files>
</IfModule>


In the php.ini file put this code:

date.timezone = "America/Toronto"


The main PHP timezone codes for Canada are:
  • America/Cambridge_Bay
  • America/Dawson
  • America/Dawson_Creek
  • America/Fort_Nelson
  • America/Edmonton
  • America/Glace_Bay
  • America/Goose_Bay
  • America/Halifax
  • America/Inuvik
  • America/Moncton
  • America/St_Johns
  • America/Toronto
  • America/Vancouver
  • America/Whitehorse
  • America/Vancouver
  • America/Winnipeg
  • America/Yellowknife

A reference of all PHP timezones is here

To verifiy the setting took effect create a phpinfo.php page. There is a tutorial on how to create a phpinfo.php file in our knowledgebase.

  • PHP, htaccess
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Change PHP version

In CPanel go to Software -> Select PHP Version.There you can select the version of PHP and...

Setting Custom PHP Options with Your Own Custom php.ini File

1. In the same directory as the files you want to affect put this in the .htaccess file:It will...

How to see all PHP settings with a phpinfo.php File

This tutorial will show you how to make a phpinfo.php file.Create a new file using the file...

PHP 7 is Faster Than PHP 5.6

Try using the "Select PHP Version" feature in CPanel to switch to PHP 7.Be aware that this will...

MYSQL no longer supported in PHP 7

As of December 31 2018 PHP 5.6 is no longer supported with security updates.This means moving to...