Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在一行中使用Carbon和Laravel设置日期格式_Php_Laravel_Laravel 5.2_Php Carbon - Fatal编程技术网

Php 在一行中使用Carbon和Laravel设置日期格式

Php 在一行中使用Carbon和Laravel设置日期格式,php,laravel,laravel-5.2,php-carbon,Php,Laravel,Laravel 5.2,Php Carbon,我从数据库中检索此日期格式: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-foot

我从数据库中检索此日期格式: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
@foreach($ticket->messages as$msg)
@foreach($ticket->messages as$msg)
@foreach($ticket->messages as$msg)

你应该写这个。希望这能解决你的问题

@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
@foreach($ticket->messages as$msg)

你应该写这个。希望这能解决你的问题

@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
@foreach($ticket->messages as$msg)
{!!\Carbon\Carbon::parse($msg->creation\u date)->diffForHumans()!!}{!!\Carbon\Carbon::parse($msg->creation\u date)->diffForHumans()!!}