Read Excel date format problem.

Topics: Developer Forum, User Forum
Jun 23, 2009 at 5:32 AM

I am using PHPEXCEL to read excel xls file and show on webpage.

I can read all data in excel file and show on the page.

But the problem is that I don't know why all date field will not show the date. I used to try any date format. The result also is a number.
For example:
The date original is
4/1/2009
But show into webpage is
39904

I don't know why? Can anyone help me to solve this problem?

Coordinator
Jun 23, 2009 at 8:24 AM

Correct. Excel dates and times are always numbers: the number of days since 01/01/1900 (or 01/01/1904 if you're using the alternate Mac 1904 calendar).

What you need to do is convert that Excel datestamp to a PHP/Unix  datestamp, that you can then pass to PHP's date() function to format as you need.

To do this, use the PHPExcel_Shared_Date::ExcelToPHP() method.