[英]Format date with Carbon and Laravel in one line
我从我的数据库中检索这个日期格式:2016-09-05T10:24:13Z
我需要得到这个日期并直接应用diffForHumans()碳方法。
我有一个票务聊天时间表:
@foreach($ticket->messages as $msg)
<div class="chat-bubble>
<div class="chat-msg">{{ $msg->message }}</div>
<div class="chat-footer">{{ $msg->creation_date }}</div> //here needs carbon diff
</div>
@endforeach
如何在一个代码行中使用我的tickets.blade.php中的Carbon?
@foreach($ticket->messages as $msg)
<div class="chat-bubble>
<div class="chat-msg">{{ $msg->message }}</div>
<div class="chat-footer">{{ $msg->creation_date->diffForHumans() }}</div> //here needs carbon diff
</div>
@endforeach
你应该写这个。 希望这将解决您的问题
@foreach($ticket->messages as $msg)
<div class="chat-bubble>
<div class="chat-msg">{{ $msg->message }}</div>
<div class="chat-footer">{{ $msg->creation_date->diffForHumans() }}</div>
</div>
@endforeach
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.