Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: Reading date format from excel to PHP

$
0
0

Hi there,

I have a problem when I tried to read an excel file to PHP. I used the PHPExcel 1.7.7 version right now.

Here is a sample from the excel 2007 file (Column A for name, and column B for date)

Jim9/17/2010
Gordon6/4/1979
Bill3/24/1987
Steve5/24/1991
Robin8/8/1964

I used this code to read the name and birthday:

include'PHPExcel/IOFactory.php';
$inputFileName = 'example.xls';echo'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format
'
; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);foreach ($sheetData as $row) {echo $row['A']."
"
;echo date_format(date_create_from_format('m-d-y', $row['B']), 'Y-m-d')."
"; }

In the end it will print something like this

Jim2010-09-17
Gordon1979-06-04
Bill1987-03-24
Steve1991-05-24
Robin2064-08-08

How do i change for the last part so the year would be 1964?


Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>