我试图将我的 Carbon 语言更改为“fr”,即我的 appServiceProvider
public function boot()
{
Carbon::setLocale('fr');
}
在我的模型中,我有
protected $appends = [
'humman_created_at'
];
public function getHummanCreatedAtAttribute(){
return $this->created_at->formatLocalized('%d %B %Y');
}
当我 dd humman_created_at 我得到"25 November 2021"
但如果我尝试了这些
$this->created_at->monthName => novembre
$this->created_at->diffForHumans() => il y a une semaine
我得到了法语返回,但我的格式日期仍然存在en