Excelreader is easy to use. I believe many PHP students need to use it to import data from Excel to the database, because it is easy to use, let's see his example.
However, when importing a date field from an Excel file, the problem arises. The first problem is the time zone and the format. I read the "d/M/y" format from Excel, and I usually use the "Y-m-d" format in MySQL. The conversion format is relatively easy. In/spreadsheet_excel_reader/EXCEL/reader. php
VaR $ dateformats = array (0xe => "d/M/Y", 0xf => "D-M-Y", 0x10 => "D-M ", 0x11 => "M-Y", 0x12 => "H: I a", 0x13 => "H: I: s ", 0x14 => "H: I", 0x15 => "H: I: s", 0x16 => "d/M/y h: I ", 0x2d => "I: s", 0x2e => "H: I: s", 0x2f => "I: S. s "); */change to VaR $ dateformats = array (0xe =>" Y-m-d ", 0xf =>" Y-m-d ", 0x10 => "M-d", 0x11 => "Y-M", 0x12 => "H: I a", 0x13 => "h: i: s a ", 0x14 =>" H: I ", 0x15 =>" H: I: s ", 0x16 => "Y-m-d h: I", 0x2d => "I: s", 0x2e => "H: I: s ", 0x2f => "I: S. s ");
$ Ifile = $ _ Get ['ifile '];
$ Upfile_type = strtolower (pathinfo ($ ifile, pathinfo_extension ));
If ($ upfile_type! = 'Xls '){
$ Mess = "{success: false, message: 'the file type you selected is not a valid Excel file! '}";
$ Mess = iconv ("gb2312", "UTF-8 // ignore", $ mess );
Echo $ mess;
Return;
}
Require_once '../excelreader/reader. php ';
// Excelfile ($ filename, $ encoding );
$ DATA = new spreadsheet_excel_reader ();
// Set output encoding.
$ Data-> setoutputencoding ('cp936 ');
$ Data-> Read ($ ifile );
Error_reporting (e_all ^ e_notice );
...