15
votes

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.

2
Note: The php-cli's php.ini file is different then apache2's php.ini file. I suggest symbolic linking one to another to keep them in sync and avoid confusion!recursion.ninja

2 Answers

29
votes

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

28
votes

Fixed this by putting

date_default_timezone_set('America/New_York');

In the actual file that was complaining.