如何在phpspreadsheet中自定义日期格式?

时间:2019-02-11 08:42:55

标签: php phpspreadsheet

我想在phpspreadsheet中自定义日期。

Feb 10, 2019 11:34:04

这是默认格式,但是我想在末尾添加PMAM

有什么方法可以自定义phpspreadsheet中的日期格式? 这两个都不起作用。

$sheet->getStyle($cell)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME1);

$sheet->getStyle($cell)->getNumberFormat()->setFormatCode('MMM dd,yyyy hh:mm:ss aa');       

1 个答案:

答案 0 :(得分:0)

您可以使用:

$birthday = date("d/m/Y", strtotime($birthday));
$sheet->getActiveSheet()->setCellValue('A'.$numRow, $birthday);
相关问题