Warning: date() It is not safe to rely on the system timezone

If after upgrading to php 5.3.x you are getting this error

Warning: date() [function.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....

Reason for this issue is that php 5.3.x requires you to set the default time-zone in your php.ini file

You have 2 option to resolve the issue.

1.  create or edit your php.ini file and add this line;


Change the actual value according to your needs. See the php time-zone manual for information

Note: if you do not have a php.ini file in the root of your website. the site will use the global / server wide php.ini by default.
If you have some script running on your website that requires some php module (example ionqube) you will need to reference the location of the script in your local php.ini file or you will get an error on your site.

2. You can add a script forcing your website to read the server time-zone.

This script needs to be loaded as close to the start of the page as possible, so the easiest way to include it in all you your site pages would be to include it into the database connection file.


// Force PHP 5.3.0+ to take time zone information from OS
if (version_compare(phpversion(), '5.3.0', '>='))
   $date_now =  @date_default_timezone_set(date_default_timezone_get());

I have used both options and believe the second one to be the better option. It is easy to implement and requires no fiddling with the php.ini file.



Cycle Africa
exelwebs VPS
Exelwebs SSL Certificates

Although we try to ensure all the articles submitted are valid it is your responsibility to make sure you have backups before you use these suggestions on your pc or websites.
We do not take any responsibility for any data-loss, loss in functionality or any problem that might arise in what-ever way or form by making use of the information on this site.

"Friends of Interakt" has no connection to the Adobe Interakt Company