情况就是这样:
在我的数据库中,我有一个表部署。表中的行也有一个字段created_at。现在我想选择created_date超过14天的所有行。但我坚持如何用Carbon做到这一点。我的查询现在看起来像这样:
$passed = Deployment::where('created_at', '>=', );
谁能帮我这个?
您可以使用subDays()
方法:
$passed = Deployment::where('created_at', '<=', Carbon::now()->subDays(14)->toDateTimeString());
你可以使用Carbon :: now() - > subDays(14)
$passed = Deployment::where('created_at', '>=', Carbon::now()->subDays(14)->toDateTimeString());
你可以在这里阅读有关碳的更多信息Carbon Documentation