HOWTO: Set Default Timezone in PHP

Setting your default timezone in PHP is a very easy task and may be needed for some applications.  If you fall into this bucket, all you need to do is….

  1. Open up your default php.ini file (or the one you wish to edit).  I can help you find your default php.ini file, if you don’t know where it is.
  2. Find the line that says ;date.timezone
  3. Uncomment that line by removing the semi-colon, then set it equal to the appropriate timezone.  For instance:
    • date.timezone = America/New_York
  4. Save the file and restart Apache

In case you’re wondering… I write these how to’s to help me remember.  Might not be so helpful for everyone else, but maybe.

HOW TO find php.ini in Ubuntu

Looking for the primary php.ini in Ubuntu to change some default settings across Apache?  No problemo.  Here are three different options for finding it:

  • Try running this <?php phpinfo(); ?> through your PHP interpreter.  This will show you where your main php.ini file is.
  • Or you can try searching for it in the shell:  find / -name php.ini
  • If all else fails, give it the old college try, and see if my setting works for you:  /etc/php5/apache2/php.ini (I’m on Ubuntu 9.10 – karmic).

This should just about do it for you, old chap.

HOWTO: Fix “Fatal error: Call to a member function toHtml() on a non-object in * on line 529″ on Magento

After upgrading to Magento v1.4.1 I was treated to the following, nasty PHP error:

Fatal error: Call to a member function toHtml()
on a non-object in * on line 529

As with most things, I’m sure others are having this problem, but fortunately the solution is easy.  Just update the file app/design/frontend/base/default/layout/page.xml by adding the tag name=”core_profiler” to the HTML element <block type=”core/profiler” output=”toHtml”/>.

The line should now look like this:
<block type=”core/profiler” output=”toHtml” name=”core_profiler”/>

Hope this helps you out.  Cheers!