PHPExcelReader and date

2009-05-13
2013-05-02
  • Santiago Russo

    Santiago Russo - 2009-05-13

    I have a web module that takes an excel list and gives back the data of certain columns in xml. The truth is that the bookstore that I mention in the title goes very well. The problem appears when i run the web site with apache under MAC (Apple); specifically the column of the dates. In this situation the dates are increased in a day and i dont know the reason.

    Example:

    Excel

    date name U$S
    10/05/2009 santiago 100
    11/05/2009 juan 75
    12/05/2009 pedro 125

    The conversion, installed the page in apache under MAC gives back the following thing to me

    XML

    11/05/2009 santiago 100
    12/05/2009 juan 75
    13/05/2009 pedro 125

     
  • Thomas Haenig

    Thomas Haenig - 2010-10-21

    I stumbled over the same problem yesterday maybe found a solution.

    I replaced the function createDate() found with a version found at

    http://www.ustrem.org/en/articles/reading-xls-with-php-en/
    and
    http://php.apsique.com/contenido/lector_excel_php_nativo

    from Nelson Hereveri

    # with the followind defines (my local/desired date/time format)

    define('AIRVIRO_DATE_FORMAT', 'd.m.Y');            // DD.MM.YYYY (en el post eran con dos puntos)
    define('AIRVIRO_HOUR_FORMAT', 'H:i:s');            // HH:MM:SS
    define('AIRVIRO_FULLDATE_FORMAT', 'd.m.Y\ H:i:s'); // DD.MM.YYYY HH:MM:SS

    # and those modifications

    #$secs = intval(floor($parteDecimal * SPREADSHEET_EXCEL_READER_MSINADAY) - $hours * 60 * 60 - $mins * 60);
    $secs = intval(ceil($parteDecimal * SPREADSHEET_EXCEL_READER_MSINADAY) - $hours * 60 * 60 - $mins * 60);

    # with 'floor' the secs value was always 1 to low

    # $utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY);
    $utcValue = $utcDays * SPREADSHEET_EXCEL_READER_MSINADAY;

    # I have no idea what the '+1' could be necessary for and for me the results now seem correct

    Also very interesting reading was about the leap year bug within Excel
    http://php.apsique.com/contenido/lector_excel_php_nativo

    Enviado por Ale (no verificado) el Mié, 10/12/2008 - 06:29.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks