Issue
I tried convert to timestamp but not working, My code is below
$date = $objPHPExcel->getActiveSheet()->getCell('A' . $x)->getFormattedValue();//output value is 9/Feb/16
echo strtotime($date);//return value is empty
It's return empty value. I want to compare Excel sheet date and PHP returned date.
Excel sheet returned date is like this ->
9/Feb/16
Solution
If the value in the cell is an MS Excel serialized timestamp, then you can get the "raw" value from the cell
$date = $objPHPExcel->getActiveSheet()
->getCell('A' . $x)->getValue();
which should return a number like 42409 for 2nd February 2016
Then use the built-in date/time conversion functions to convert that either to a unix timestamp, or to a PHP DateTime object
$date = PHPExcel_Shared_Date::ExcelToPHP($date); // returns a unix timestamp
echo date('Y-m-d H:i:s', $date);
or
$date = PHPExcel_Shared_Date::ExcelToPHPObject($date); // returns a DateTime object
echo $date->format('Y-m-d H:i:s');
Answered By - Mark Baker Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.