Laravel: Get time between two timestamps in diffForHumans format (Carbon)

时间:2017-08-05 11:23:03

标签: php laravel

I am trying to get the time between two dates in diffForHumans format, can anyone help me out to why its throwing this error?

Code:

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

Error:

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 个答案:

答案 0 :(得分:1)

建议:将您的日期时间字段定义为日期,以便Laravel可以将其视为碳实例,因此您可以执行以下操作:

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