php - PHPExcel returns a weird date format -


when use phpexcel's getformattedvalue() on row / column that, in libreoffice calc, shows 02/19/2015 23:59:40 42067.458524537 back. how convert 02/19/2015 23:59:40?

my php code follows:

<?php include('/path/to/phpexcel.php');  $filepath = 'filename.xlsx';  $inputfiletype = phpexcel_iofactory::identify($filepath); $objreader = phpexcel_iofactory::createreader($inputfiletype);  $excel = $objreader->load($filepath); $worksheet = $excel->getsheet();  echo $worksheet->getcellbycolumnandrow(3, 4)->getformattedvalue(); 

ms excel stores dates serialized value, real number count of number of days since baseline of either 1st january 1900 or 1st december 1904, depending on whether spreadsheet created using windows 1900 calendar or mac 1904 calendar.

a serialized value of 42067.458524537 corresponds date of 4th march 2015 @ 11:00:17 (with windows 1900 calendar)

if you've used phpexcel's getformattedvalue() method, should convert serialized value formatted date/time string based on number format mask applied cell.... assuming didn't set loaddataonly when loading spreadsheet file.

if need convert raw ms excel serialized value unix timestamp or php datetime object, can use phpexcel_shared_date::exceltophp() or phpexcel_shared_date::exceltophpobject() methods respectively; use native php date() of datetime::format() functionality format want.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -