Use PHPExcel import database, date data issues

  When a data table into PHPExcel MySQL, the time field in the data type to date, the introduction of the discovery time database shows '0000-00-00'.

A database to match the date format, time format as Excel , to get found by PHPExcel is floating-43110, after the check information to know the time format by default conventional format in Excel, read all floating point, so we To lower its conversion.

$d = 25569;
$t = 24 * 60 * 60;

$date = gmdate('Y-m-d',($rowData[0][6] - $d) * $t);

  Since excel in time it is counted from the beginning of 1990, but the time stamp from the 1970 count, so to minus 70 years. Is 25569.

Excel time format can also be set to text mode, but can not guarantee the unity of all people to upload.

 

Guess you like

Origin www.cnblogs.com/liuqingyang/p/11595899.html