title: PHP Timezone database is corrupt error
body: <p>I have a wordpress website which suddenly stopped working today. When I look at the logs I see and error:</p>
  
  <blockquote>
    <p>[error] [client 50.78.108.177] PHP Fatal error:  strtotime(): Timezone
    database is corrupt - this should <em>never</em> happen!</p>
  </blockquote>
  
  <p>After reading up on google one person said that they discovered a permissions problem in <em>/usr/share/zoneinfo</em>. I tried changing the permissions to 777, 775, 770 and I still keep on getting the same error. I am running php PHP 5.3.2 on Ubuntu 10.04.3 LTS. Any suggestions or recommendations would be helpful.If all else fails I'm going to try downgrading to an earlier version of php but I wanted to try other things before doing that.</p>
  
  <p>thanks,
  Timnit</p>
  
  <p><strong>Update</strong><br>
  just in case it helps: the error points to <code>strtotime</code> in the function below</p>
  
  <pre><code>function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
      $m = $mysqlstring;
      if ( empty( $m ) )
              return false;
  
      if ( 'G' == $dateformatstring )
              return strtotime( $m . ' +0000' );
  
      $i = strtotime( $m );
  
      if ( 'U' == $dateformatstring )
              return $i;
  
      if ( $translate )
              return date_i18n( $dateformatstring, $i );
      else
              return date( $dateformatstring, $i );
  }
  </code></pre>
  
  <p><strong>Update#2:</strong><br>
  for now I have fixed the problem by simply having the function above <code>return false;</code> without performing anything. However I still haven't figured out the root cause of the problem.</p>
  
  <p><strong>update#3:</strong>  </p>
  
  <pre><code>var_dump($dateformatstring)
  </code></pre>
  
  <blockquote>
    <p>string(5) "d.m.y" string(1) "m" string(5) "d.m.y" string(1) "m"
    string(5) "d.m.y" string(1)  "m"</p>
  </blockquote>
  
  <pre><code>var_dump($mysqlstring)
  </code></pre>
  
  <blockquote>
    <p>string(19) "2011-10-20 05:35:01" string(19) "2011-10-20 05:35:01"
    string(19) "2011-10-20 05:25:22" string(19) "2011-10-20 05:25:22"
    string(19) "2011-10-19 05:10:06" string(19) "2011-10-19 05:10:06"</p>
  </blockquote>
  
  <p><strong>update#4</strong>:<br>
  there is another code snippet that is generating the error log below:</p>
  
  <blockquote>
    <p>PHP Fatal error:  date(): Timezone database is corrupt - this should
    <em>never</em> happen! in /srv/www/motionthink.com/public_html/wp-admin/includes/class-wp-filesystem-direct.php
    on <strong>line 346,</strong> referer:
    wp_root_directory/wp-admin/plugins.php?plugin_status=upgrade</p>
  </blockquote>
  
  <pre><code>309         function dirlist($path, $include_hidden = true, $recursive = false) {
    310                 if ( $this-&gt;is_file($path) ) {
    311                         $limit_file = basename($path);
    312                         $path = dirname($path);
    313                 } else {
    314                         $limit_file = false;
    315                 }
    316 
    317                 if ( ! $this-&gt;is_dir($path) )
    318                         return false;
    319 
    320                 $dir = @dir($path);
    321                 if ( ! $dir )
    322                         return false;
    323 
    324                 $ret = array();
    325 
    326                 while (false !== ($entry = $dir-&gt;read()) ) {
    327                         $struc = array();
    328                         $struc['name'] = $entry;
    329 
    330                         if ( '.' == $struc['name'] || '..' == $struc['name'] )
    331                                 continue;
    332 
    333                         if ( ! $include_hidden &amp;&amp; '.' == $struc['name'][0] )
    334                                 continue;
    335 
    336                         if ( $limit_file &amp;&amp; $struc['name'] != $limit_file)
    337                                 continue;
    338 
    339                         $struc['perms']         = $this-&gt;gethchmod($path.'/'.$entry);
    340                         $struc['permsn']  = $this-&gt;getnumchmodfromh($struc['perms']);
    341                         $struc['number']        = false;
    342                         $struc['owner']         = $this-&gt;owner($path.'/'.$entry);
    343                         $struc['group']         = $this-&gt;group($path.'/'.$entry);
    344                         $struc['size']          = $this-&gt;size($path.'/'.$entry);
    345                         $struc['lastmodunix']= $this-&gt;mtime($path.'/'.$entry);
    346                         $struc['lastmod']   = date('M j',$struc['lastmodunix']);
    347                         $struc['time']          = date('h:i:s',$struc['lastmodunix']);
    348                  $struc['type']          = $this-&gt;is_dir($path.'/'.$entry) ?   'd:'f';
    349 
  </code></pre>
  
  <p><strong>Update#5:</strong><br>
  doing a <code>php -i | fgrep -i date</code> returns</p>
  
  <blockquote>
    <p>Build Date => Dec 13 2011 18:43:02</p>
  
  <pre><code>date
  date/time support =&gt; enabled
  date.default_latitude =&gt; 31.7667 =&gt; 31.7667
  date.default_longitude =&gt; 35.2333 =&gt; 35.2333
  date.sunrise_zenith =&gt; 90.583333 =&gt; 90.583333
  date.sunset_zenith =&gt; 90.583333 =&gt; 90.583333
  date.timezone =&gt; no value =&gt; no value
  </code></pre>
  </blockquote>
  
  <p>then I edited the php.ini file to set the timezone to "America/Los Angeles" and got this output</p>
  
  <pre><code>date/time support =&gt; enabled
  date.default_latitude =&gt; 31.7667 =&gt; 31.7667
  date.default_longitude =&gt; 35.2333 =&gt; 35.2333
  date.sunrise_zenith =&gt; 90.583333 =&gt; 90.583333
  date.sunset_zenith =&gt; 90.583333 =&gt; 90.583333
  date.timezone =&gt; America/Los_Angeles =&gt; America/Los_Angeles
  </code></pre>
  
  <p>I then restarted apache2. I still get the error</p>