我有一个PHP代码,它将显示日期格式,即
{{date('F d, Y', strtotime($po->due_date))}}
它将输出类似"2016 年 9 月 2 日"的内容,如何将此日期格式化为"2016 年 9 月 2 日"?
这是M d, Y
.我建议您在模型中$dates
属性中添加due_date
:
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'due_date',
];
然后,您可以$po->due_date->format('M d, Y')
显示它,而不是date('M d, Y', strtotime($po->due_date))