Joseph
Joseph

Reputation: 85

Reading xls Date Values with php excel reader

I am using PHPExcel to read date cells in excel file that have values like 'Mar-13' but it is returning integer values like '41791'. Please, what do I need to do make sure that the date reads in correctly?

Upvotes: 1

Views: 1902

Answers (1)

Gerard
Gerard

Reputation: 180

Excel stores dates as serialized timestamps (number of days since 1/1/1900), which you can convert to Unix timestamp and format it with standard php date functions

$unix_timestamp = ($cell_value - 25569) * 86400;
$phpdate = date("m-d-Y", $unix_timestamp);

Upvotes: 6

Related Questions