[英]How to customize Carbon diffForHumans in Laravel
i am newbie of laravel.我是 laravel 的新手。 I wanna use a carbon class.
我想使用碳 class。 I want to show on my blade like this: 8 days, 12 hours, 33 minutes remanining time.
我想在我的刀片上显示这样:8天,12小时,33分钟的剩余时间。
My source code;我的源代码;
$date = Carbon::parse($currentTime);
$now = Carbon::now('Europe/Istanbul');
$date->locale('tr');
if ($date >= $now) {
$diff = $date->diffForHumans($now);
return $diff;
}
What can i do?我能做些什么?
You should use like this;你应该这样使用;
$diff = $date->diffForHumans($now, ['long' => true, 'parts' => 4]);
Diff for humans take a propertiy.人类的差异具有属性。
I found out easily this solution on the documentation https://carbon.nesbot.com/docs/我在文档https://carbon.nesbot.com/docs/上轻松找到了这个解决方案
Just type on search "human" and It'll show to you some examples.只需输入搜索“人类”,它就会向您展示一些示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.