[How To] - Fix date.timezone for php5.3

Rating: 2.7/5
Views: 1763


PHP 5.3 now requires that we all have a specific timezone set, either by date.timezone or date_default_timezone_set();

If neither of these are set, we get a few WARNING error like the following:

"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"

To fix this, simply add the following line of code to your php.ini file:

__________________________________________
date.timezone="America/New_York"<hr>
__________________________________________

You can also define date_default_timezone_set setting before date.timezone function:

was
__________________________________________

echo date('Y-m-d H:i:s', time());
<hr>
__________________________________________

now
__________________________________________

date_default_timezone_set('UTC');
echo date('Y-m-d H:i:s', time());
<hr>
__________________________________________

Follow-up and discuss this topic in our forums


Output generated by ProSupport
Copyright © 2024 ProPanelSystems.com - ProSupport v0.9.1 Rev. 1