gpt4 book ai didi

php - Laravel Carbon 从当前日期减去天数

转载 作者:IT王子 更新时间:2023-10-29 01:06:44 26 4
gpt4 key购买 nike

我正在尝试从 created_at 日期距今天 30 天 的模型“用户”中提取对象。

Carbon::now() ==> 我想要 ==> Carbon::now() - 30 天

$users = Users::where('status_id', 'active')
->where( 'created_at', '<', Carbon::now())
->get();

如何实现?

最佳答案

使用 subDays()方法:

$users = Users::where('status_id', 'active')
->where( 'created_at', '>', Carbon::now()->subDays(30))
->get();

关于php - Laravel Carbon 从当前日期减去天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41122265/

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