我想将我的视图中获取的日期语言从英语更改为法语。
{{ strftime("%d %B %Y, %H:%M", strtotime($article->created_at)) }}
我想将我的视图中获取的日期语言从英语更改为法语。
{{ strftime("%d %B %Y, %H:%M", strtotime($article->created_at)) }}
我们可以使用translatedFormat方法来采用另一种方法。
Carbon::setLocale('fr');
echo $base_weight_category->created_at->translatedFormat('l jS F Y');
我们可以看到结果为2020年4月2日星期四
首先设置 Carbon
的语言环境,然后再访问
Carbon::setLocale('fr');
$date_to_show_in_view = $article->created_at->diffForHumans();
对于您的第二个查询(获取2018年3月15日
),请使用以下内容 -
<?php
setlocale(LC_TIME, 'French');
echo $base_weight_category->created_at->formatLocalized('%d %B %Y');
?>
UTF-8
作为字符集,这可能是语言支持问题。 - Sohel0415public function getReservationDateFormatAttribute() {
return Carbon::parse($this->reservation_date)->locale(app()->getLocale())->translatedFormat('d F Y');
}
$model_name->reservation_date_format;
Carbon::parse($this->reservation_date)->locale(app()->getLocale())->translatedFormat('d F Y');