Laravel 使用diffForHumans和Strotototime

Laravel 使用diffForHumans和Strotototime,laravel,php-carbon,Laravel,Php Carbon,我正在尝试将diffForHumans与字符串格式的日期一起使用。我使用strotime将字符串转换为Unix时间戳。问题是现在我得到了一个无法将整数转换为时间的错误。我错过了什么 这是我的密码 <td>{{strtotime($user['scan'])->diffForHumans(time())}}</td> {{strotime($user['scan'])->diffForHumans(time())} $user['scan']是一个字符串日期使用p

我正在尝试将diffForHumans与字符串格式的日期一起使用。我使用strotime将字符串转换为Unix时间戳。问题是现在我得到了一个无法将整数转换为时间的错误。我错过了什么

这是我的密码

<td>{{strtotime($user['scan'])->diffForHumans(time())}}</td>
{{strotime($user['scan'])->diffForHumans(time())}

$user['scan']是一个字符串日期

使用parse。默认情况下,将日期与当前时间进行比较

<td>{{ \Carbon\Carbon::parse($user['scan'])->diffForHumans() }}</td>
{{\Carbon\Carbon::parse($user['scan'])->diffForHumans()}