import an excel file with PHP Excel Reader
I'm trying to use 开发者_StackOverflow中文版this class to import a large amount of data. Most of the data is being read correctly, however I have two date columns which are giving me problems.
The dates are in the format DD/MM/YYYY
and the values returned are one day ahead of those in the spreadsheet. For example, 04/03/2011 00:00
becomes 04/03/2011 02:00
I have tried accessing the data like this:
$data->sheets[$sheet]['cells'][$row][$col];
I have also tried using the raw data:
$data->sheets[$sheet]['cellsInfo'][$row][$col]['raw']
Which returns the date as a unix timestamp but still it is one day ahead of what it should be.
Is there any way I can force the class to return the value of the column as a simple string?
The solution is simple - why don't you just deduct a day from the timestamp, or from the date you fetch?
$wrongDateTimestamp = "1304398800";
$rightDateTimestamp = strtotime("-1 day", $wrongDateTimeStamp); // Or alternatively - $wrongDateTimeStam - 86400
$rightDate = date("d/m/Y", $rightDateTimestamp);
Hope this helps.
Shai.
精彩评论