I have a system that developed using Yii2 framework, and I've an Excel file that consist a date value imported to the system, for example:
ExcelFile
-------------------------------------------------
Name | Birthdate | Place of Birth
-------------------------------------------------
Archie | 1995-09-18 | Nevada
Gerry | 1989-01-23 | Gotham
I'm using PHPExcel for reading the data to PHP, and then the data set to new array, for example
Array
Array
(
[0] => Array
(
[0] => Archie
[1] => 42265
[2] => Nevada
)
[1] => Array
(
[0] => Gerry
[1] => 36217
[2] => Gotham
)
)
That is the array result after reading data from Excel file.
You can see the result above, the data in array [0][1]
and [1][1]
doesn't consist date value like the date data from Excel file.
Anyone have an idea how to solve this? or anyone knows why I got this?
Edtited
Code in Controller
This is the code for reading the Excel file
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$arrayData = [];
for ($row = 1; $row <= $highestRow; ++$row) {
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
if (!is_null($rowData[0][0])) {
$arrayData[] = array_map(function($values) {
$tempArrayKey = [];
foreach ($values as $key => $value) {
$newKey = $key + 1;
$tempArrayKey[] = $newKey . '_' . $value;
}
return $tempArrayKey;
}, $rowData);
Any help would be appreciated. Thanks