Sunday, February 27, 2011

Timezone errors with TimThumb

I was recently setting up a WordPress site using a theme that relied on TimThumb for post thumbnails. The images were not showing, and I couldn’t see any immediate errors. The URL for the missing image looked like this:
Entering that directly into the browser exposed the error:
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.

Searching the web provided the answer:
Php 5.3.0 & WP 2.8 (It is not safe to rely on the system’s timezone)

But my MacBook Air didn’t have a /etc/php.ini file – It did however, have a /etc/php.ini.default file so I copied that, then had to change the permissions, and edited it, and restarted apache:
sudo cp /etc/php.ini.default /etc/php.ini
sudo chmod u+w /etc/php.ini
sudo vi /etc/php.ini
sudo /usr/sbin/apachectl restart

I added the following on the second line of /etc/php.ini:

Now, the URL above works and my images are showing correctly.

No comments:

Post a Comment