Fixing PHP Timezone Issue in Snow Leopard (10.6)

September 5, 2009

I always forget about my PHP development environment when I upgrade OS X.  Apple must think it’s really funny to make developers figure out what’s changed and how to fix it.  Snow Leopard brings us PHP 5.3, which apparently requires a value in the date.timezone setting or your code will produce warning messages.  Unfortunately, this value isn’t set in the php.ini file shipped with 10.6.  Here’s how to fix:

  1. Open Terminal
  2. Run this command to rename the php.ini.default file to php.ini:  mv /etc/php.ini.default /etc/php.ini
  3. Open the new php.ini file in vi (or other editor if you wish) with superuser: sudo vi /etc/php.ini
  4. Search for the date.timezone key and set it to your timezone.  Mine is America/New_York.  You can find a complete list here.
  5. Save the php.ini file.
  6. Restart Apache with this command:  sudo apachectl restart

Previous post:

Next post: