I have an excel file which has a time input.
Mar 01, 2018 | Thursday | 8:00 AM | 5:00 PM
Mar 02, 2018 | Friday | 8:00 AM | 5:00 PM
B
Formart the data before you read it.
For example:
cell data 2020/10/13 19:00:00
Access directly will get 44117.791666667
$sheet->toArray();
Format before access will get 2020-10-13 19:00:00
$row_num = $sheet->getHighestDataRow();
$sheet->getStyle("H1:H$row_num")->applyFromArray(array("numberFormat"=>array("formatCode"=>'yyyy-mm-dd hh:mm:ss'))); // H is the datatime row
$sheet->toArray();
Thankfully I have found the answer just now.
$in = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($time_in);
echo gmdate("g:i a", $in);
Hopefully, this could be useful for others.