1

I'm trying to use 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?

3
  • And where does this class come from? Provide a link? There may be many different products by this name. Commented Sep 19, 2011 at 9:30
  • Are you sure you're reading the right row/col? Commented Sep 19, 2011 at 9:32
  • I am experiencing the same problem. Linke to PHPExcel reader: phpexcel.codeplex.com I suspect something with the way Excel is recording the date. The spreadsheet is generated in USA and IT operations are in Australia (where I am), not sure if that is relevant Commented Feb 12, 2015 at 22:33

1 Answer 1

1


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.

Sign up to request clarification or add additional context in comments.

1 Comment

While this "works", I think understanding why all dates are recording as a day ahead (or a day less as it were in Excel) would be better as if it is not consistantly out by a day you are changing the outcome of the process

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.