2017-08-05 202 views
0

我试图在diffForHumans格式中获取两个日期之间的时间,任何人都可以帮我解释为什么它会抛出这个错误?Laravel:在diffForHumans格式(Carbon)中获取两个时间戳之间的时间

代码:

{{ Carbon\Carbon::createFromTimestamp($clientLogin->exit_timestamp)->diffForHumans($clientLogin->enter_timestamp) }} 

错误:

Type error: Argument 1 passed to Illuminate\Cookie\Middleware\EncryptCookies::encrypt() must be an instance of Symfony\Component\HttpFoundation\Response, instance of Illuminate\View\View given

回答

1

建议:定义你的日期时间字段,日期,以便Laravel已经可以把那么作为碳的实例,所以你可以做这样的事情:

$clientLogin->exit_timestamp->subDays($clientLogin->enter_timestamp)->diffForHumans();