1

I have xlsx tables and I use PhpSpreadsheet to parse them. One Column is date format. The problem is that PhpSpreadsheet returns the values from date-formatted cells in an unspecified format:

2-Jan-19 (in Excel) and 43467 (After Exporting)

And I need to save entire tables exactly as they look like in Excel Format, like "2-Jan-19" not "43467"

I've been read Retrieve Date From Table Cell, But it can't solve my problem

Below is the code I have right now:

        $spreadsheet = $reader->load($_FILES['berkas_excel']['tmp_name']);
        $sheetData = $spreadsheet->getSheet(0)->toArray();
        echo count($sheetData);
        for($i = 3;$i < count($sheetData) ;$i++)
        {
                $kode = $sheetData[$i]['0'];
                $tgl = $sheetData[$i]['1']; //This is where the Date Column 
                $shift_rec = $sheetData[$i]['2'];
                $grup = $sheetData[$i]['3'];
                $pekan = $sheetData[$i]['4'];
                $bulan = $sheetData[$i]['5'];
        }

I hope somebody can help me to get "2-Jan-19" as the result, so I can insert it into my DB after that,

Thanks to anyone who willing to answer/help my problem right now

  • Does this answer your question? [How to retrieve date from table cell using PhpSpreadsheet?](https://stackoverflow.com/questions/44304795/how-to-retrieve-date-from-table-cell-using-phpspreadsheet) – Dave Oct 30 '19 at 12:36
  • The post you reference has the exact information you need to solve your problem. As the answer says, that number is the number of days since 1900 and there is a built-in function you may use to convert it. – Dave Oct 30 '19 at 12:37
  • @dave Yes it has, but I need whole column not only some cells....when I try that it doesn't get me correct answer for my problem – Mahatma Wisnhu Nov 01 '19 at 08:17
  • You have to do the conversion for each cell in a column. There isn't a function to convert all of the cells in a particular column. – Dave Nov 02 '19 at 22:01

0 Answers0