It is not safe to rely on the system’s timezone settings

Recently I have been having the following error on my PHP code every time I call the PHP function date();  Mostly when running it on my local test server.

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

Cause: Since PHP5.1.0 the E_RESTRICT setting causes PHP to report error for every call
to a date/time function, if no default time is set.

Fix:
There are 2 approaches to  resolving this.

  1. Set time setting to your PHP script with the function date_default_timezone_set();  with the intended time zone/location eg: for GMT one can use date_default_timezone_set(‘Europe/London’);
  2. Set time setting to your php.ini file by editing the line ;date.timezone = to date.timezone = “Europe/London” or you required location. This is good for setting a server wide time setting.

Technorati Tags: , , , , ,

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>