Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:31:03+00:00 2026-06-02T17:31:03+00:00

I am using simplexlsx.class.php to read xlsx file type. It’s giving problems when the

  • 0

I am using simplexlsx.class.php to read xlsx file type. It’s giving problems when the file contain date field in the excel file.

Sample output:

In the file data:

Day Date
Thursday 2/2/2012
Friday 2/3/2012

Program output:

Day Date

Thursday 40941
Friday 40942

It’s not give the correct date

<?php

if (isset($_FILES['file'])) {

require_once "simplexlsx.class.php";

$xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );

echo '<h1>Parsing Result</h1>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';

list($cols,) = $xlsx->dimension();

foreach( $xlsx->rows() as $k => $r) {
    if ($k == 0) continue; // skip first row
    echo '<tr>';
    for( $i = 0; $i < $cols; $i++)
    {

        echo '<td>'.( (isset($r[$i])) ? $r[$i] : '&nbsp;' ).'</td>';

    }
    echo '</tr>';
}
echo '</table>';
}

?>
<h1>Upload</h1>
<form method="post" enctype="multipart/form-data">
*.XLSX <input type="file" name="file"  />&nbsp;&nbsp;<input type="submit" value="Parse" />

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:31:05+00:00Added an answer on June 2, 2026 at 5:31 pm

    Those are the correct dates, just in Excel’s internal format: number of days since Jan 1st 1900 (allowing for 1900 being a leap year). Clearly something in the simplexlsx class is converting the xlsx date value to the Excel internal format.

    I’ve not come across simplexlsx before (which surprises me as I thought I knew all the Excel file reader/writer libraries for PHP)… but somewhere in the code there must be a method to handle that conversion, so I’d imagine that there would also be a method for the reverse (converting Excel timestamp to PHP)

    EDIT

    The method you want is in the code:

    function unixstamp( $excelDateTime ) {
        $d = floor( $excelDateTime ); // seconds since 1900
        $t = $excelDateTime - $d;
        return ($d > 0) ? ( $d - 25569 ) * 86400 + $t * 86400 : $t * 86400;
    }
    

    I make no guarantees that it’s accurate

    EDIT FURTHER

    function unixstamp( $excelDateTime ) {
        $d = floor( $excelDateTime ); // seconds since 1900
        $t = $excelDateTime - $d;
        return ($d > 0) ? ( $d - 25569 ) * 86400 + $t * 86400 : $t * 86400;
    }
    
    
    $dateVal = 40941;
    $unixDateVal = unixstamp($dateVal);
    var_dump($unixDateVal);
    echo date('d-M-Y',$unixDateVal);
    

    gives

    float 1328140800
    

    which looks remarkably like a unix timestamp value in the correct range for this year, and sure enough:

    02-Feb-2012
    

    So looks like it works to me

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP, I can convert MySQL data or static table data to csv, Excel,
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using the HTML5 File API I can get the Binary String representation of a
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using php's DOMDocument->LoadHTMLFile('test.html'); keeps on returning an error to me, reporting for an error
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
Using boost python I need create nested namespace. Assume I have following cpp class
Using VBA. My script moves a file into a directory. If that filename already

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.