我从我的数据库中检索这个日期格式: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?
答案 0 :(得分:0)
@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
答案 1 :(得分:0)
你应该写这个。希望这能解决您的问题
@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