- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
fecha_desde->format("l j F -6ren">
在 Blade View 中我有这段代码
{{ \Carbon\Carbon::setLocale("es") }}
{{ $registro->fecha_desde->format("l j F Y") }}<br />
{{ $registro->fecha_desde->formatLocalized("%A %d %B %Y") }}<br />
{{ $registro->fecha_desde->diffForHumans() }}
这不起作用,它返回:
Friday 30 December 2016
Friday 30 December 2016
dentro de 1 semana
因此,format() 和 formatLocalized 总是以英文格式返回日期。diffForHumans 返回本地化日期(在本例中为西类牙语)。
我错过了什么吗?无法相信“Carbon 的 formatLocalized”没有返回本地化的格式化日期....
最佳答案
我找到了两种用其他语言输出日期的方法。在 AppServiceProvider 中添加这个
Carbon::setLocale('es');
setlocale(LC_TIME,'es_ES');
//This output dates in spanish
在 App.php 中用“es”代替“en”。现在您可以使用 FormatLocalized,所有 Carbon 函数都将使用您在 setLocale 中指定的语言。
注意:如果您使用的是 Oracle 数据库,请添加:
setlocale(LC_TIME, config('app.locale'));
改为:
setlocale(LC_TIME,'es_ES');
关于php - Carbon formatLocalized 在 Blade 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41252687/
我正在使用 carbon 和 laravel 5.5 并希望格式化日期以仅以三个字母格式显示月份 (ie: January => Jan, February => Feb, ...)
我正在使用 carbon 和 laravel 5.5 并希望格式化日期以仅以三个字母格式显示月份 (ie: January => Jan, February => Feb, ...)
在 Blade View 中我有这段代码 {{ \Carbon\Carbon::setLocale("es") }} {{ $registro->fecha_desde->format("l j F
我想返回阿拉伯本地时间,如下所示 9:00 õ 所以我在AppServiceProvider类的启动方法中设置了carbon区域设置 class AppServiceProvider extends
我不确定这是否是一个错误,所以我要先寻求建议,因为我对 ReactJS 很陌生 我正在尝试实现 Google 距离矩阵来获取距离。 (如果有任何预构建的reactjs替代解决方案,请告诉我) 我的代码
我是一名优秀的程序员,十分优秀!