title: phpexcel date is reading wrong format
body: <p>I know there are a lot of questions similar to this but none of them actually has helped. </p>
  
  <p>I'm having a cell in my excel file that I have to read.</p>
  
  <p><img src="https://i.stack.imgur.com/7FhTc.png" alt="Cell Date in Excel"></p>
  
  <p>and the format in the excel file is like below <img src="https://i.stack.imgur.com/8qrKR.png" alt="Date Format In Excel"></p>
  
  <p>In my php code I have it in a function that gets the sheet name and cell to read the cell .</p>
  
  <pre><code>$cellDate = $xls-&gt;getSheetByName($sheet)-&gt;getCell($cell)-&gt;getValue();
  </code></pre>
  
  <p><strong>I've also tried this with getFormattedValue() and got same result</strong></p>
  
  <p>I then get the format with this </p>
  
  <pre><code>$format = $xls-&gt;getSheetByName($sheet)-&gt;getCell($cell)-&gt;getStyle()-&gt;getNumberFormat()-&gt;getFormatCode();
  </code></pre>
  
  <p>when I echo this out in PHP it shows the date as </p>
  
  <pre><code>13/4/2015 
  </code></pre>
  
  <p>and for the format it shows </p>
  
  <pre><code>mm-dd-yyyy
  </code></pre>
  
  <p>where it show as dd-mm-yyyy</p>
  
  <p>I now need to get Y-m-d format of these I've tried using all the available functions in PHPExcel but it's still the result is not correct.</p>
  
  <p>I can't hard code the format because there are multiple cells with multiple formats and I need this to understand by itself</p>
  
  <p>I've tried using </p>
  
  <pre><code>$objPHPExcel-&gt;getActiveSheet()
  -&gt;getStyle('A1')
  -&gt;getNumberFormat()
  -&gt;setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2 );
  </code></pre>
  
  <p>I really need this and I've already wasted 1 week on it.</p>
  
  <p>Is there anyway to tell PHPEXCEL to parse whatever date is in the cell to Y-m-d format ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As I was reading through the comments I went back and checked the function I wrote, I found that one of the cells [even] that it's formatted in Excel ,it's parsing a wrong format which in that case was a General Format;</p>
  
  <p>I then got the value of getValue() and getFormattedValue() and compared these two if they are not the same that means it's formatted correctly and i can use PHPExcel to get dates from it.</p>
  
  <p>BUT , (There is always a but). Thanks to Microsoft and its excel I'm still not able to differ 1st Feb 2016 and 2nd Of January ! which forever remains the question.</p>
  
  <p>My only recommendation is to never trust excel formats !</p>