Tuesday, March 20, 2007

date.timezone setting error in MediaWiki, phpMyAdmin in Cygwin and Linux

I've only encountered this problem in Cygwin and install-from-source-code Linux. Apparently after PHP 5.1 released, it generates following warning/error message about timezone information (read entry at Date/time support).

It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 '... for '...' instead in ... on line ....

Anyway this is how I fixed the problem.

  1. Add following line in PHP code
    date_default_timezone_set("America/Denver");

  2. Edit PHP.ini file
    To solve the problem, you can enter the timezone setting manually on php.ini file. You can change the following lines in php.ini
    [Date]
    ;date.timezone =

    to
    [Date]
    date.timezone = America/Denver

    Here are the lists of supported timezones.

  3. Using TZ environment variable
    This is how I fixed the problem in Cygwin. Enter the following lines in ther terminal if you have access to shell. However as of PHP 5.1.0, this will also generate warning message.
    TZ='US/Mountain;
    export TZ

No comments:

Post a Comment