【问题标题】:how to customize date format in phpspreadsheet?如何在 phpspreadsheet 中自定义日期格式?
【发布时间】:2019-02-11 08:42:55
【问题描述】:

我想在 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');       

【问题讨论】:

标签: php phpspreadsheet


【解决方案1】:

你可以使用:

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

【讨论】:

    猜你喜欢
    • 2020-10-19
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 2020-07-08
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多