php-excel-reader 导入excel日期多一天解决办法返回列表
上传时间:2015-02-05 内容关键字:php-excel,php-excel-reader 导入,excel日期多一天, 导入excel日
使用 php-excel-reader 导入excel文件到mysql数据库中,当excel包含时间18/10/2011这样的字段时,导入后的日期会有1天的增加会变成10/19/2011。
方法一、修改read.php文件
$utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY);
换成
$utcValue = round(($utcDays) * SPREADSHEET_EXCEL_READER_MSINADAY);
方法二、
解决方法
把时间字段转成时间搓再减1天
$wrongDateTimestamp = strtotime(str_replace('/', '-', '18/10/2011'));
$rightDateTimestamp = strtotime("-1 day", $wrongDateTimeStamp); // 或者 $wrongDateTimeStam – 86400
$rightDate = date("d/m/Y", $rightDateTimestamp);
参考文件:
http://stackoverflow.com/questions/7468737/import-an-excel-file-with-php-excel-reader
https://code.google.com/p/php-excel-reader/issues/detail?id=132
声明:未作说明,则本文为php教程分享网站原创。转载务必注明出处。
谢谢!