[英]Format date with Carbon and Laravel in one line
I retrieve this date format from my database: 2016-09-05T10:24:13Z 我从我的数据库中检索这个日期格式:2016-09-05T10:24:13Z
I need get this date and apply a diffForHumans() carbon method directly. 我需要得到这个日期并直接应用diffForHumans()碳方法。
I have a ticket messages chats timeline: 我有一个票务聊天时间表:
@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
How can I use Carbon in my tickets.blade.php in one code line? 如何在一个代码行中使用我的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
You should write this. 你应该写这个。 Hopefully this will solve your problem
希望这将解决您的问题
@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.