Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date PHPExcel日期到字符串_Date_Phpexcel - Fatal编程技术网

Date PHPExcel日期到字符串

Date PHPExcel日期到字符串,date,phpexcel,Date,Phpexcel,我如何不能使用excel中的日期。 我使用for循环来输出文件 echo $sheet -> getCellByColumnAndRow($j,$i)->getValue(); 但输出结果如下所示: Date | Name --------------- 425831 | Peter 425831 | Nils 2016-08.01我是怎么得到这样的东西的?你得到的是1970年的秒数。尝试类似的方法,如中所述: 但是,您也可以使用以下方法在PHP中对其进行转换: dat

我如何不能使用excel中的日期。 我使用for循环来输出文件

echo $sheet -> getCellByColumnAndRow($j,$i)->getValue();
但输出结果如下所示:

 Date  |  Name
---------------
425831 |  Peter
425831 |  Nils

2016-08.01我是怎么得到这样的东西的?

你得到的是1970年的秒数。尝试类似的方法,如中所述:

但是,您也可以使用以下方法在PHP中对其进行转换:

date('Y-m-d',PHPExcel_Shared_Date::ExcelToPHP($sheet -> getCellByColumnAndRow(1,12)->getValue()));

我尝试了echo date('Y-m-d',$sheet->getCellByColumnRow(1,12)->getValue());我得到了1970-01-01。但是为什么从1870年开始的
。。。。1900年1月1日(或Mac上的1904年)起的天数;这是MS Excel序列化的时间戳,而不是Unix时间戳没有看到链接回显日期('Y-m-d',PHPExcel_Shared_date::ExcelToPHP($sheet->GetCellByColumnRow(1,12)->getValue());作品感谢您的帮助感谢您的澄清@MarkBaker我甚至不知道MS使用了自己的标准。
getFormattedValue()
可能比
getValue()
更好,如下所示:(除非在加载文件时已将loadDataOnly指定为true,否则它会将MS Excel序列化的时间戳转换为反映日期的格式化字符串
date('Y-m-d',PHPExcel_Shared_Date::ExcelToPHP($sheet -> getCellByColumnAndRow(1,12)->getValue()));