【发布时间】:2020-11-26 23:42:47
【问题描述】:
我正在尝试在我的模板 PhpWord 中更改日期格式的输出,但它不起作用。 在我的控制器中,我有:
public function edit(Attestationstagiaire $attestationstagiaire, $downloadName = null)
{
$id = $attestationstagiaire->id;
$desc1 = Attestationstagiaire::find($id);
$my_template = new \PhpOffice\PhpWord\TemplateProcessor(public_path('templates/stagiaire/attestation.docx'));
$my_template->setValue('id', $desc1->id);
$my_template->setValue('prenoms', $desc1->prenoms);
$my_template->setValue('nom', $desc1->nom);
$my_template->setValue('date_de_naissance', $desc1->date_de_naissance);
$my_template->setValue('lieu_de_naissance', $desc1->lieu_de_naissance);
try{
$my_template->saveAs(storage_path("Document.docx"));
}catch (Exception $e){
//handle exception
}
return response()->download(storage_path("Document.docx"));
}
行内-> $my_template->setValue('date_de_naissance', $desc1->date_de_naissance); 我在输出文档中的日期格式显示为 12-07-2020,但我想要 2020 年 12 月 12 日。 我能怎么做? 感谢您的帮助!
【问题讨论】:
标签: laravel date-format phpword