简体   繁体   English

Laravel Carbon diffForHumans 转换为天

[英]Laravel Carbon diffForHumans convert to Days

I have domains table in table ı have expired_at columns.我在表中的域表有 expired_at 列。

I want to show remaining days but if domains expired 30 days ago its saying just 30 or if will expire after 30 days its showing 30我想显示剩余天数,但如果域在 30 天前过期,则显示 30 天,或者如果将在 30 天后过期,则显示 30

how ı can do like this ;我怎么能这样;

55 days
-55 days

I used 'parts' = 1,2,3,4,5,5我使用了“零件”= 1,2,3,4,5,5

{{  \Illuminate\Support\Carbon::createFromTimeStamp(strtotime($domain->expired_at))->diffForHumans()}}

You can pass a param to the diffInDays function :您可以将参数传递给 diffInDays 函数:

 \Illuminate\Support\Carbon::createFromTimeStamp(strtotime($domain->expired_at))->diffInDays(now(), false)

Adding the false param allow to bypass the absolute value添加false参数允许绕过绝对值

source : https://carbon.nesbot.com/docs/#api-difference来源: https : //carbon.nesbot.com/docs/#api-difference

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

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