I'm having a very similar problem. I absolutely cannot get the date to output correctly. I had it outputting as the correct date, but it would subtract 1 from the day. I found the updated reader.php file on this site, but when I loaded it, it now makes every date 01/01/1970. AHHHH! If anyone knows how to fix this, please post. Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
01/01/1970 is the beginning of Unix time - all dates stored in unixtime are measured in seconds from that moment. That suggests that you are passing it a value of zero. HTH.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Per question from benriddell (below)...
Under the PPH-ExcelReader project select the tracker tab and then Patches. You will see the ParseXL code listed there. I got a notice a while back that matchy provided a patch of my code too. I have not checked it out but it is there too.
Per the date error...
I understand the date frustrations. It led me to write totally distinct code because fixing the date issue, as well as other problems, was not just a simple fix. The issue of appearing off by 1 day is not just a math error of 1 it has to do with calling the wrong date functions related to UCT and local time. The 1 day error will come and go depending on the time of day you test the code and your time zone. For date formating codes for PHP differ significantly from Excel format codes, which prohibits a simple one-to-one character mapping used in the original code. I just rewrote it. My code includes some test case spreadsheets for validation too.
-dvc
******************************
Hi,
I've been banging my head against some Excel date format issues.
I see that I am not the first.
There is mention of your ParseXL in the discussion areas,
but I have been unable to find the code itself (not on
Sourceforge or pear.php.net).
Where can I find it please?
Thanks!
-Ben Riddell
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying hard to get the date to be outputted the way it was put in. I have not exceeded. I use MS Excel 2003.
test.xls:
MODEL PID YEAR DATE COST
ABC 123 2007 10-Oct-05 $20.06
DEF 456 2005 01-Jan-02 $123.00
HIJ 789 2002 10-Jun-78 $546.98
The DATE column is formatted as date->dd-mmm-yy. I have tried removing the formatting, custom formatting, etc.. I cannot get the output to be right.
example.php
<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once 'reader.php';
$data = new Spreadsheet_Excel_Reader();
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
echo "\"".$data->sheets[0]['cells'][$i][$j]."\",";
}
echo "\n";
}
?>
output:
"MODEL", "PID", "YEAR", "DATE", "COST",
"ABC", "123", "2007", "38635", "20.06",
"DEF", "456", "2005", "37257", "123",
"HIJ", "789", "2002", "28651", "546.98",
So what am I doing wrong?
I'm having a very similar problem. I absolutely cannot get the date to output correctly. I had it outputting as the correct date, but it would subtract 1 from the day. I found the updated reader.php file on this site, but when I loaded it, it now makes every date 01/01/1970. AHHHH! If anyone knows how to fix this, please post. Thanks.
01/01/1970 is the beginning of Unix time - all dates stored in unixtime are measured in seconds from that moment. That suggests that you are passing it a value of zero. HTH.
Per question from benriddell (below)...
Under the PPH-ExcelReader project select the tracker tab and then Patches. You will see the ParseXL code listed there. I got a notice a while back that matchy provided a patch of my code too. I have not checked it out but it is there too.
Per the date error...
I understand the date frustrations. It led me to write totally distinct code because fixing the date issue, as well as other problems, was not just a simple fix. The issue of appearing off by 1 day is not just a math error of 1 it has to do with calling the wrong date functions related to UCT and local time. The 1 day error will come and go depending on the time of day you test the code and your time zone. For date formating codes for PHP differ significantly from Excel format codes, which prohibits a simple one-to-one character mapping used in the original code. I just rewrote it. My code includes some test case spreadsheets for validation too.
-dvc
******************************
Hi,
I've been banging my head against some Excel date format issues.
I see that I am not the first.
There is mention of your ParseXL in the discussion areas,
but I have been unable to find the code itself (not on
Sourceforge or pear.php.net).
Where can I find it please?
Thanks!
-Ben Riddell