0

I use PhpExcelReader--
include 'excel_reader.php'; // include the class

// creates an object instance of the class, and read the excel file data
$excel = new PhpExcelReader;

Data Read and Function Call--

$excel->read('test.xls');
sheetData($excel->sheets[0]);

Function Code--

function sheetData($sheet) 
{
    while($x <= $sheet['numRows']) 
    {
        if(@$sheet['cells'][$x][1])
        {
            while($y <= $sheet['numCols']) 
            {
                $cell = isset($sheet['cells'][$x][$y]) ? $sheet['cells'][$x][$y] : '';
                echo $cell = @date($cell)."<br/>";
            }
         }
     }
}

It shows only numbers like 36400
And after then i tried

echo $cell = @date("Y-m-d",$cell)."<br/>";

But it shows the default value like 1970-01-01
But my data 2004-05-12

MuteX
  • 183
  • 1
  • 1
  • 13

2 Answers2

0

The Date field in Excel is "Number of days since Jan 0 1900", where as the time in PHP is "Number of Seconds since Jan 01 1970 00:00". Conversion should be pretty easy from there.

goodevans
  • 136
  • 5
0

Use this function detailed here https://phpexcel.codeplex.com/discussions/219301

$PHPDate = PHPExcel_Shared_Date::ExcelToPHP($cell);
echo date("Y-m-d", $PHPDate);
Phil
  • 1,996
  • 1
  • 19
  • 26