15

Upgrading to a new server, I two repeated errors:

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 'America/New_York' for 'EST/-5.0/no DST' instead in...

and

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 'America/New_York' for 'EST/-5.0/no DST' instead in

How do I go about fixing these?

Code in question is this:

'date' => date("Y-M-d",strtotime($Array['_dateCreated'])),

I've tried putting this in an include at the top of all my pages:

<?php
date_default_timezone_set('America/New_York');
?>

Thanks in advance for your help.

Keefer
  • 2,269
  • 7
  • 33
  • 50

2 Answers2

29

date.timezone in php.ini can fix this globally.

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
Nowhy
  • 2,894
  • 1
  • 16
  • 13
  • 1
    For some reason my /etc/php.ini file's additions like date.timezone seem to be ignored even after restarting apache. – Keefer Jan 11 '12 at 15:51
  • Turns out that the /etc/php.ini isn't the right one, rather the [domain]/httpdocs/etc/php.ini is the one that has an effect. – Keefer Jan 11 '12 at 17:01
  • 2
    You can find out which `php.ini` your server cares about by doing `phpinfo()` and looking for `Loaded Configuration File`. – Basti Jul 15 '15 at 12:59
28

Fixed this by putting

date_default_timezone_set('America/New_York');

In the actual file that was complaining.

Keefer
  • 2,269
  • 7
  • 33
  • 50
  • 1
    i prefer this . because i don't want to update my php.ini file. Also, you can set default timezone to your project globally – Franz Sep 09 '20 at 08:11