Home > tips > PHP – date() [function.date]: ERROR on OS X

PHP – date() [function.date]: ERROR on OS X

If you have enabled php5 support on Snow Leopard modifying the file at “/etc/apache2/httpd.conf” uncommenting the line:

#LoadModule php5_module        libexec/apache2/libphp5.so

you might get in trouble using php due to a misconfiguration of php.ini.
As far as I am concerned, if you try to execute some php scripts, an error like this will pop-up:

Message: 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 ‘UTC’ for ‘GMT/0.0/no DST’ instead

This is caused by php5.3, that requires a timezone to be set in the php.ini. In order to fix this, you have to configure php, modifying the php.ini file. There isn’t any php.ini on os x by default, so you have to create it from the sample one provided. Open the terminal and type:

cd /private/etc
sudo cp php.ini.default php.ini

now edit that php.ini file and look for the line:

date.timezone = "timezone_here"

And overwrite timezone_here with your timezone code from the PHP.net Website.

Categories: tips Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment