Date in format of 5/9/2011 gets converted to INT

Oct 5, 2011 at 8:34 PM

The value of the cell is 5/9/2011


This is the code being used to read data:

$dob = ($excel->getActiveSheet()->getCell('P' . $i)->getValue());

I want to keep 5/9/2011 as a string but for some reason the code returns "40672".

How can I keep the original value ?


Thanks in advance!

Oct 5, 2011 at 8:39 PM

That is how Excel saves it. You must convert it with something like...

$date = PHPExcel_Style_NumberFormat::toFormattedString(round($date), "M/D/YYYY");
The documentation and other discussions have more info if needed.

Oct 5, 2011 at 8:42 PM

Thanks Scott! That worked.