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:

http://192.168.0.191/~paul/mysite/wp-content/themes/mytheme/timthumb.php?src=/wp-content/uploads/2011/02/broccoli1.png&h=185&w=185&zc=1&q=90
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:

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:

  date.timezone="Sydney/Australia"

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


Leave a Reply

You must be logged in to post a comment.