如何在Cakephp中更改日期格式

时间:2018-12-10 15:03:18

标签: php cakephp cakephp-2.0

我使用此编码显示发票日期

    $this->SetX(135);
    $this->SetFont('Arial','B',14);
    $this->Cell(70,8,___('Date:')." ".$invoice['date'],0,0,'C',false);

,但以Y,m,d格式显示 我想以d,m,Y格式显示它

请问我该如何解决?

2 个答案:

答案 0 :(得分:0)

我使用此鳕鱼固定了它:

        $this->Cell(70,8,___('Date:')." ".date("d-m-Y", strtotime($invoice['date'])),0,0,'C',false);

答案 1 :(得分:0)

一种更清洁的方法是使用CakeTime::format()

$this->Cell(70,8,___('Date:')." ".CakeTime::format($invoice['date'], '%d-%m-%Y'),0,0,'C',false);

相关问题