title: PHP & MySQL are returning different dates for same timestamp
body: <p>I am encountering a slightly frustrating problem and I have a feeling there is a simple solution to it. When I pass the same UNIX timestamp to the PHP <code>date</code> and MySQL <code>FROM_UNIXTIME</code> methods they are returning two very different dates. I would like to return a value from MySQL that matches the one returned by PHP.</p>
  
  <p>Here is the code I am currently using along with it's output. The timestamp provided represents the date <code>Tue, 01 Jan 2013 (01/01/2013)</code>. Also for reference, here are the format values.</p>
  
  <p><strong>MySQL Format</strong></p>
  
  <ul>
  <li>%j = Day of year (001..366).</li>
  <li>%m = Month, numeric (00..12).</li>
  <li>%y = Year, numeric (two digits).</li>
  </ul>
  
  <p><strong>PHP Format</strong></p>
  
  <ul>
  <li>z = The day of the year starting from 0 (0 through 365).</li>
  <li>m = Numeric representation of a month, with leading zeros (01 through 12). </li>
  <li>y = A two digit representation of a year (Examples: 99 or 03).</li>
  </ul>
  
  <p><strong>MySQL Query</strong></p>
  
  <pre><code>SELECT FROM_UNIXTIME(1357018200, '%j-%m-%y');
  -&gt; 366-12-12
  </code></pre>
  
  <p><strong>PHP Code</strong></p>
  
  <pre><code>echo date('z-m-y', 1357018200);
  -&gt; 0-01-13
  </code></pre>
  
  <p>Any help would be greatly appreciated, thanks for your time. :)</p>
  
  <p><strong>Other Information</strong></p>
  
  <ul>
  <li><strong>MySQL Version</strong>: 5.5.23</li>
  <li><strong>MySQL system_time_zone</strong>: CDT</li>
  <li><strong>MySQL time_zone</strong>: SYSTEM</li>
  <li><strong>PHP date_default_timezone_get</strong>: America/Chicago (CDT)</li>
  </ul>