0

I have a PHP program that reads Excel Sheets using Php Excel. The excel sheet has only one column which is formatted to 'yyyy-mm-dd hh-mm-ss'.

When I read this excel sheet using Php Excel, everything works fine until I get to a date above 2038.

Now, I have read into the 2038 problem and I thought I may be able to detect it and return an error message to the user when they enter a date >=2038 but I cannot since the dates come in wrong.

What's even worse is they come in as valid dates.

Here is an example of different values I've tried (this is the array after it is read into PHP):

    INPUT == Exactly as written in excel sheet
    OUTPUT == The output the PHPExcel Reader returns in the array
    OUTPUT DATE            INPUT DATE
    ----------------------------------------------
    2036-02-13 02:42:08 -- 2988-10-31 00:00:00
    ----------------------------------------------
    2028-08-16 11:03:28 -- 2300-10-31 00:00:00
    ----------------------------------------------
    1902-09-24 17:31:44 -- 2038-10-31 00:00:00
    ----------------------------------------------
    2037-10-31 00:00:00 -- 2037-10-31 00:00:00
    ----------------------------------------------

The output appears to be completely random, but still a valid date.

I want to be able to catch dates above 2038 to return a message to the user.

I am running PHP 32 bit.

This is the code that reads it into the array and prints it:

$objPHPExcel = PHPExcel_IOFactory::load ( $this->pathToExcelFile);
$sheetData = $objPHPExcel->getActiveSheet ()->toArray ( null, true, true, false );
print_r ($sheetData, true);

Ideas?

Kellen Stuart
  • 7,775
  • 7
  • 59
  • 82

0 Answers0