Date value from Excel to PHP

$sheet -> getCell(‘A1’) -> getValue()

If the value is a “date”, then this statement will get a “number”.

To convert this number for PHP to use:

//This way will cause incorrect result because of unknown reason
$birth = $sheet->getCellByColumnAndRow(1, $row)->getValue(); 
//PHPExcel will read as GMT+0
$birth = PHPExcel_Shared_Date::ExcelToPHP( $birth );

//If PHP timezone is UTC+0
echo var_dump(date('Y-m-d', $birth));

//If PHP timezone is not UTC+0
echo var_dump(gmdate('Y-m-d', $birth));
//This way create a formatted string directly
$birth = $sheet->getCellByColumnAndRow(1, $row)->getValue(); 
$birth = PHPExcel_Style_NumberFormat::toFormattedString($birth, "YYYY-M-D");
//Get time value only
$cell = $sheet->getCellByColumnAndRow($i, $row_index);
$value = PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), 'hh:mm:ss');

Reference: