gpt4 book ai didi

php - Laravel:无法在 Blade 中使用 Carbon diffForHumans

转载 作者:行者123 更新时间:2023-12-05 08:53:59 29 4
gpt4 key购买 nike

在 string.. 上调用成员函数 diffForHumans()我实际上在做的是在 Blade 中获取的日期调用 diffForHumans。

<span>{{$data['date']->diffForHumans()}}</span>

最佳答案

{{ \Carbon\Carbon::parse($data['date'])->diffForHumans() }}

如前所述,您的 $data['date'] 可能已经不是 Carbon 的实例,因此需要进行解析。以上将解析碳,解析它并获得差异。

关于php - Laravel:无法在 Blade 中使用 Carbon diffForHumans,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51726523/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com