如何在laravel中更改日期语言? [英] How to change the date language in laravel?
本文介绍了如何在laravel中更改日期语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我认为日期的语言从英语更改为法语
I want to change the language of the date i get in my view from english to french
{{ strftime("%d %B %Y, %H:%M", strtotime($article->created_at)) }}
推荐答案
首先设置 Carbon
语言环境,然后访问
Set Carbon
locale first, then access
Carbon::setLocale('fr');
$date_to_show_in_view = $article->created_at->diffForHumans();
第二次查询(要获得 15 Mars 2018
),请使用此-
For your second query(to get 15 Mars 2018
), use this-
<?php
setlocale(LC_TIME, 'French');
echo $base_weight_category->created_at->formatLocalized('%d %B %Y');
?>
这篇关于如何在laravel中更改日期语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文