簡體   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