📜  更改 laravel 视图页面中的日期格式 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:58             🧑  作者: Mango

代码示例1
// date('d-m-Y', strtotime($user->from_date));

public function convertDate($date,$format = 'd-m-Y'){
    return date($format, strtotime($date));
}
or
public function convertDate($date,$format = 'd/m/Y'){
        return \Carbon\Carbon::parse($date)->format($format);
}
$user->convertDate($user->from_date);
//$user->convertDate($user->from_date,'Y-m-d'); with format