Skip to content
Advertisement

Laravel : How to add days to datetime field?

How to add days to datetime field in Laravel?

For example,
there is a updated_at field in articles table:

JavaScript

I want to add 30 days to updated_at field.

In Carbon, it could be done like this:

JavaScript

But how to do it in above example?

Advertisement

Answer

Since updated_at and created_at fields are automatically cast to an instance of Carbon you can just do:

JavaScript

Or if you want it in a separate variable:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement