[英]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.