Date Format PhpSpreadSheet

0

I have an Excel file with several fields, including a date type field. I am using PhpSpreadSheet to read the Excel cells and load them in a query but I realized that when reading the cell that contains a date, it reads it as a number, for example in the excel I have 06/01/2018 and php lo returns as 43106. Any idea how to read as such on 06/01/2018 or how to convert the whole number?

    
asked by Alejandro Flores 10.11.2018 в 02:13
source

1 answer

0

To obtain the correct format, use this own PhpSpreadSheet function that will return a DateTime object.

$excelTimestamp = 43106; //valor recogido de la celda del archivo excel
$objetoDateTime = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelTimestamp);
    
answered by 28.11.2018 в 10:47