This is the case:
In my database I have a table deployments. The rows in the table also have a field created_at. Now I would like to select all rows where the created_date is older than 14 days. But I'm stuck on how to do this with Carbon. My query now looks like this:
$passed = Deployment::where('created_at', '>=', );
Can anyone help me with this?
You can use the subDays()
method:
$passed = Deployment::where('created_at', '<=', Carbon::now()->subDays(14)->toDateTimeString());
You can use Carbon::now()->subDays(14)
$passed = Deployment::where('created_at', '>=', Carbon::now()->subDays(14)->toDateTimeString());
You can read more about Carbon its feature here Carbon Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With