Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - It is not safe to rely on the system's timezone settings

I have just activated/installed PHP and mySQL on my Mac and all seemed to be going well until I accessed a table which used dates.

On the live server - where I was previously developing the site - exactly the same page worked fine.

On my local site I get the following messages for each row in the table:

Warning: strtotime() [function.strtotime]: 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 'Europe/London' for 'BST/1.0/DST' instead in /Users/mysite/Sites/testsite/index.php on line 26

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 'Europe/London' for 'BST/1.0/DST' instead in /Users/mysite/Sites/testsite/index.php on line 26

Any ideas how to stop this. I'm guessing I need to change a setting somewhere.

like image 269
Tom Avatar asked Dec 16 '22 14:12

Tom


1 Answers

Any ideas how to stop this.

The error message tells you how to stop this.

You are required to use the date.timezone setting or the date_default_timezone_set() function.

Update your PHP installation's php.ini (likely /etc/php.ini) file to have a date.timezone setting, or use date_default_timezone_set() in your scripts.

You're only now seeing this because it starts happening in PHP 5.3+.

like image 106
ceejayoz Avatar answered Dec 19 '22 06:12

ceejayoz