我想在一个领域的时候有人在等待展示,我想通过在几分钟当前时间减去created_at时间去做这些事情。
这是我的表
<thead>
<tr>
<th scope="col">Ordernummer</th>
<th scope="col">E-mail</th>
<th scope="col">Kenteken</th>
<th scope="col">Wachttijd</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
@foreach($orders as $order)
<tr>
<th scope="row">{{ $order->ordernumber }}</th>
<td scope="row">{{ $order->email }}</td>
<th scope="row">{{ $order->numberplate }}</th>
<td scope="row">{{ $order->created_at }}</td>
<td scope="row">
@if( $order->status == 0)
Open
@else
Afgehandeld
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
和其中该写入<td scope="row">{{ $order->created_at }}</td>
我想表明那里分钟的差别。
由于已经
答案 0 :(得分:1)
我想你的$order->created_at
是碳的实例,所以你可以使用:
<td scope="row">{{ $order->created_at->diffInMinutes(\Carbon\Carbon::now()) }} minutes ago</td>
如果$order->created_at
是纯的MySQL格式不是碳实例只是转换/创建:
\Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $order->created_at)->diffInMinutes(\Carbon\Carbon::now())
答案 1 :(得分:0)
您可以像这样使用 Carbon
来计算以分钟为单位的差异
<td scope="row">{{ now()->diffInMinutes($order->created_at) }}</td>
答案 2 :(得分:0)
您可以使用 Carbon::diffInMinutes
获得不同的分钟数,
或者您可以使用 Carbon::diffForHumans
获得更具可读性的语句
$order->created_at->diffInMinutes(Carbon::now());
// 那就是:5
$order->created_at->diffInMinutes(Carbon::now());
这将是:5 分钟前