You are here

howto: fixing php 5.3 timezone error

i upgraded my fedora boxes to php 5.3 and i started seeing these errors:

SYSTEM WARNING: date_default_timezone_get() []: 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 
'Europe/Helsinki' for 'EEST/3.0/DST' instead

after a little bit of research the solution was to enable a parameter in /etc/php.ini

date.timezone = Africa/Cairo

i found my appropriate timezone from the php online manual

on restarting my web server, the problem disappeared


a much simpler and faster method would be

export city=`cat /etc/sysconfig/clock | grep ZONE | cut -d= -f2 | sed -s 's/"//g'`
sed -i 's+;date.timezone =+date.timezone = '$city' +g' /etc/php.ini