Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"date(): It is not safe to rely on the system's timezone settings..."

Tags:

timezone

php

I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server.

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">  <h4>A PHP Error was encountered</h4>  <p>Severity: Warning</p> <p>Message:  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 'America/New_York' for 'EDT/-4.0/DST' instead</p> <p>Filename: libraries/Log.php</p> <p>Line Number: 86</p>  </div> 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 'America/New_York' for 'EDT/-4.0/DST' instead in /filelocation right here/system/libraries/Log.php on line 86  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 'America/New_York' for 'EDT/-4.0/DST' instead in /filelocation right here/system/libraries/Log.php on line 99 <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">  <h4>A PHP Error was encountered</h4>  <p>Severity: Warning</p> <p>Message:  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 'America/New_York' for 'EDT/-4.0/DST' instead</p> <p>Filename: libraries/Log.php</p> <p>Line Number: 99</p>  </div> 
like image 652
user1852837 Avatar asked May 27 '13 01:05

user1852837


2 Answers

You probably need to put the timezone in a configuration line in your php.ini file. You should have a block like this in your php.ini file:

[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = America/New_York 

If not, add it (replacing the timezone by yours). After configuring, make sure to restart httpd (service httpd restart).

Here is the list of supported timezones.

like image 129
CtrlX Avatar answered Sep 22 '22 17:09

CtrlX


If you cannot modify your php.ini configuration, you could as well use the following snippet at the beginning of your code:

date_default_timezone_set('Africa/Lagos');//or change to whatever timezone you want 

The list of timezones can be found at http://www.php.net/manual/en/timezones.php.

like image 28
Babatunde Adeyemi Avatar answered Sep 22 '22 17:09

Babatunde Adeyemi