繁体   English   中英

Laravel:以diffForHumans格式(碳)获取两个时间戳之间的时间

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

我正在尝试以diffForHumans格式获取两个日期之间的时间,有人可以帮助我解释为什么会diffForHumans此错误吗?

码:

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

错误:

类型错误:传递给Illuminate \\ Cookie \\ Middleware \\ EncryptCookies :: encrypt()的参数1必须是Symfony \\ Component \\ HttpFoundation \\ Response的实例,Illuminate \\ View \\ View的实例已给定

建议:将datetime字段定义为日期,这样Laravel就可以将其视为碳实例,因此您可以执行以下操作:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM