[英]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.